{"id":4654,"date":"2015-06-17T10:15:56","date_gmt":"2015-06-17T15:15:56","guid":{"rendered":"http:\/\/www.thejuliagroup.com\/blog\/?p=4654"},"modified":"2015-06-17T10:19:51","modified_gmt":"2015-06-17T15:19:51","slug":"making-life-less-complicated-sas-enterprise-guide","status":"publish","type":"post","link":"https:\/\/www.thejuliagroup.com\/blog\/making-life-less-complicated-sas-enterprise-guide\/","title":{"rendered":"Making Life Less Complicated: SAS Enterprise Guide"},"content":{"rendered":"<p>Sometimes, you can know too much programming for your own good. Yesterday, I was working on analyzing a data set and can I just say here that SAS&#8217;s inability to handle mixed-type arrays is the bane of my existence. (In case you don&#8217;t know, if you mix character and numeric variable types in an array, SAS will give you an error. If you know an easy way around this, you will be my new best friend.)<\/p>\n<p>I started out doing all kinds of fancy things, using<\/p>\n<p>ARRAY answersc{*} _char_ ;<\/p>\n<p>to get all of the character variables in an array and the DIM function to give the dimension of an array.<\/p>\n<p>There were various reasons why creating new variables that were character using the PUT function or numeric using the INPUT function was a bad idea.<\/p>\n<p>It occurred to me that I was making the whole process unnecessarily complicated. I had a relatively small data set with just a few variables that needed to be changed to character. So, I opened the original CSV file in SAS Enterprise Guide by selecting IMPORT DATA and picking COMMA from the pull-down menu for how fields are delimited.<\/p>\n<p><a href=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2015\/06\/sasegimp1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-4655\" src=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2015\/06\/sasegimp1.png\" alt=\"opening in SAS EG\" width=\"450\" height=\"198\" srcset=\"https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2015\/06\/sasegimp1.png 618w, https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2015\/06\/sasegimp1-300x132.png 300w\" sizes=\"auto, (max-width: 450px) 100vw, 450px\" \/><\/a><\/p>\n<p>Next, for each of the variables, I changed the name, label and type to what I wanted it to be.<\/p>\n<p><a href=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2015\/06\/sasegimp2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-4656\" src=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2015\/06\/sasegimp2.png\" alt=\"change properties\" width=\"450\" height=\"193\" srcset=\"https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2015\/06\/sasegimp2.png 719w, https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2015\/06\/sasegimp2-300x129.png 300w\" sizes=\"auto, (max-width: 450px) 100vw, 450px\" \/><\/a><\/p>\n<p>If you&#8217;re one of those people who just click, &#8220;NEXT&#8221; over and over when you are importing your data you may not be aware that you can change almost everything in those field attributes.\u00a0 To change the data in your to-be-created SAS data set, click in the box labeled TYPE. Change it from number to string, as shown below. Now you have character variables.<br \/>\n<a href=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2015\/06\/sasegimp3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-4657\" src=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2015\/06\/sasegimp3.png\" alt=\"change here\" width=\"450\" height=\"118\" srcset=\"https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2015\/06\/sasegimp3.png 699w, https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2015\/06\/sasegimp3-300x79.png 300w\" sizes=\"auto, (max-width: 450px) 100vw, 450px\" \/><\/a>Nice! Now I have my variables all changed to character.<\/p>\n<p>One more minor change to make my life easier.<\/p>\n<p><a href=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2015\/06\/sasegimp4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-4658\" src=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2015\/06\/sasegimp4.png\" alt=\"change length\" width=\"450\" height=\"173\" srcset=\"https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2015\/06\/sasegimp4.png 567w, https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2015\/06\/sasegimp4-300x115.png 300w\" sizes=\"auto, (max-width: 450px) 100vw, 450px\" \/><\/a><\/p>\n<p>We had some spam in our file, with spambots answering the online pretest and resulting in an input format and output format length of 600. Didn&#8217;t I just say that you can change almost anything in those field attributes? Why, yes, yes I did. Click in the box on that variable and a window will pop up that allows you to change the length.<\/p>\n<p>That&#8217;s it. Done!<\/p>\n<p><a href=\"http:\/\/www.thejuliagroup.com\/blog\/?p=4651\">Which left me time to start on the data analysis that you can read about here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes, you can know too much programming for your own good. Yesterday, I was working on analyzing a data set and can I just say here that SAS&#8217;s inability to handle mixed-type arrays is the bane of my existence. (In case you don&#8217;t know, if you mix character and numeric variable types in an array,&#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,8],"tags":[],"class_list":["post-4654","post","type-post","status-publish","format-standard","hentry","category-software","category-technology"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/posts\/4654","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=4654"}],"version-history":[{"count":2,"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/posts\/4654\/revisions"}],"predecessor-version":[{"id":4660,"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/posts\/4654\/revisions\/4660"}],"wp:attachment":[{"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/media?parent=4654"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/categories?post=4654"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/tags?post=4654"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}