{"id":1541,"date":"2011-07-17T12:47:00","date_gmt":"2011-07-17T17:47:00","guid":{"rendered":"http:\/\/www.thejuliagroup.com\/blog\/?p=1541"},"modified":"2011-07-17T12:47:00","modified_gmt":"2011-07-17T17:47:00","slug":"stripping-data-the-easy-way-in-sas","status":"publish","type":"post","link":"https:\/\/www.thejuliagroup.com\/blog\/stripping-data-the-easy-way-in-sas\/","title":{"rendered":"Stripping data the easy way in SAS"},"content":{"rendered":"<p>Been working with SAS a lot lately to get the data in shape for a new client. Here&#8217;s one of the problems I ran across.<\/p>\n<blockquote><p>We want to get the average pay rate for people who got jobs as a result of our client&#8217;s services. However, when one of the people they served did not get a job, the pay rate is listed as &#8220;no&#8221;. When the person did get a job it&#8217;s listed as something like $11.00\/hr .<\/p><\/blockquote>\n<p>Obviously, this is a character variable, and equally obviously, what I would like to do is:<\/p>\n<ol>\n<li>Change the &#8220;no&#8221; values to missing.<\/li>\n<li>Remove the &#8220;$&#8221;, &#8220;\/&#8221; and &#8220;hr&#8221;<\/li>\n<li>Change the variable type from character to numeric<\/li>\n<\/ol>\n<p><strong>Why not just do a couple of Replace commands in Excel?<\/strong><\/p>\n<p>We have a contract with this client for the fiscal year and we expect, like almost all of our clients, that this contract will be renewed and we&#8217;ll work with them for years to come.\u00a0 I&#8217;ll have to do that replace every month, unless I get them to change the way they enter their data and I think that is bad service to ask our clients to change for my convenience. They&#8217;re paying <em>us<\/em> to make life easier for <em>them<\/em>, not the other way around.<\/p>\n<p>Here&#8217;s how easy this is to fix<\/p>\n<p><code>Data services ;<br \/>\nset in.report7_11 ;<br \/>\nattrib jobpay length = 8\u00a0 ;<br \/>\njobpay = compress(earnings,'$\/hrno') ;<\/code><\/p>\n<p>The ATTRIB statement creates a new variable that is numeric. The COMPRESS function strips all of these characters out of the value for the earnings variable, &#8216;$\/hrno&#8217; \/<\/p>\n<p>Done.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Been working with SAS a lot lately to get the data in shape for a new client. Here&#8217;s one of the problems I ran across. We want to get the average pay rate for people who got jobs as a result of our client&#8217;s services. However, when one of the people they served did not&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[9],"tags":[],"class_list":["post-1541","post","type-post","status-publish","format-standard","hentry","category-software"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/posts\/1541","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/comments?post=1541"}],"version-history":[{"count":1,"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/posts\/1541\/revisions"}],"predecessor-version":[{"id":1542,"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/posts\/1541\/revisions\/1542"}],"wp:attachment":[{"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/media?parent=1541"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/categories?post=1541"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/tags?post=1541"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}