{"id":5453,"date":"2017-08-05T11:58:17","date_gmt":"2017-08-05T16:58:17","guid":{"rendered":"http:\/\/www.thejuliagroup.com\/blog\/?p=5453"},"modified":"2017-08-12T11:55:57","modified_gmt":"2017-08-12T16:55:57","slug":"getting-excel-data-into-sas-studio-beyond-the-defaults","status":"publish","type":"post","link":"https:\/\/www.thejuliagroup.com\/blog\/getting-excel-data-into-sas-studio-beyond-the-defaults\/","title":{"rendered":"Getting Excel Data into SAS Studio: Beyond the Defaults"},"content":{"rendered":"<p><a href=\"http:\/\/www.thejuliagroup.com\/blog\/?p=5333\">A while back, I wrote a post on getting your Excel data into SAS Studio the quick and easy wa<\/a>y. However, \u00a0I hear you saying,<\/p>\n<p>What about ME? What about MY needs? What if I don&#8217;t want my data written to the working directory? What if my file has the names at the top and I want to keep those names?<\/p>\n<p>First of all, open a program file and run some code that assigns the LIBNAME to the directory where you want your data stored. It should look like this but whatever is in the quotation marks should be where your data are stored.<\/p>\n<p>LIBNAME\u00a0mydata &#8220;\/courses\/d1234566789&#8221; ;<br \/>\nrun;<\/p>\n<p>Second, upload your Excel File<\/p>\n<p><a href=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2017\/08\/sasexcel1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5454\" src=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2017\/08\/sasexcel1.png\" alt=\"sasexcel1\" width=\"628\" height=\"675\" srcset=\"https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2017\/08\/sasexcel1.png 628w, https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2017\/08\/sasexcel1-279x300.png 279w\" sizes=\"auto, (max-width: 628px) 100vw, 628px\" \/><\/a><\/p>\n<p>Under FILES, select the folder where you would like your data stored. Click on the UPLOAD FILES button (the arrow pointing up at the top of the screen) and then click CHOOSE FILES to go to where the file is stored on your computer. Select that file, click the button on the pop-up window that says UPLOAD. Now you have your Excel file, uploaded but you want a SAS file.<a href=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2017\/08\/sasExcel2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5455\" src=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2017\/08\/sasExcel2.png\" alt=\"sasExcel2\" width=\"446\" height=\"266\" srcset=\"https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2017\/08\/sasExcel2.png 446w, https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2017\/08\/sasExcel2-300x179.png 300w\" sizes=\"auto, (max-width: 446px) 100vw, 446px\" \/><\/a><\/p>\n<p>Go under TASKS and UTILITIES and click the arrow to select UTILITIES and then select IMPORT DATA.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2017\/08\/sasExcel3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5456\" src=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2017\/08\/sasExcel3.png\" alt=\"sasExcel3\" width=\"619\" height=\"440\" srcset=\"https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2017\/08\/sasExcel3.png 619w, https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2017\/08\/sasExcel3-300x213.png 300w\" sizes=\"auto, (max-width: 619px) 100vw, 619px\" \/><\/a><\/p>\n<p>On the right, you&#8217;ll see this big window that says DRAG AND DROP YOUR FILE HERE.<\/p>\n<p><a href=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2017\/08\/SASExcel4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5457\" src=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2017\/08\/SASExcel4.png\" alt=\"file list\" width=\"347\" height=\"300\" srcset=\"https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2017\/08\/SASExcel4.png 347w, https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2017\/08\/SASExcel4-300x259.png 300w\" sizes=\"auto, (max-width: 347px) 100vw, 347px\" \/><\/a><\/p>\n<p>In the left pane, open the FILES directory and go to where you saved your Excel file. Drag it into the window. Once you&#8217;ve done that, this wi If you stopped here, you would have the file written to the working directory, and named import.<\/p>\n<p><a href=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2017\/08\/SASExcel6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5459\" src=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2017\/08\/SASExcel6.png\" alt=\"import option\" width=\"218\" height=\"142\" \/><\/a><\/p>\n<p>If you want to change that, click the button that says CHANGE.<\/p>\n<p><a href=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2017\/08\/SASExcel7.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5460\" src=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2017\/08\/SASExcel7.png\" alt=\"changing default name in boxes\" width=\"519\" height=\"480\" srcset=\"https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2017\/08\/SASExcel7.png 519w, https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2017\/08\/SASExcel7-300x277.png 300w\" sizes=\"auto, (max-width: 519px) 100vw, 519px\" \/><\/a><\/p>\n<p>This pops up. Don&#8217;t see the directory you want? Did you run the LIBNAME statement at the very beginning of this post to assign a library reference to that directory? For shame! You think I just make this stuff up? Go back and do it now.<\/p>\n<p>Okay, should you be concerned that your library name is greyed out? No, you should not. That just means you cannot change the name of your library reference here. If you wanted to change that library name from &#8220;<em>mydata&#8221;<\/em> to &#8220;<em>yourdata<\/em>&#8221; you&#8217;d have to do it in the LIBNAME statement.<\/p>\n<p>Type the name you want for the data set.\u00a0<strong>Do not forget to click SAVE\u00a0<\/strong>or you may as well have skipped this step.<\/p>\n<p>Click the little running guy at the top of the window.<\/p>\n<p>Before you go, notice that SAS also generates code for you. If, like me, you anticipate that your data may change and you may need to do this again, you can copy and paste the code generated by SAS and save it in a program file. Run it again to recreate your data set. How likely is that to happen? \u00a0Well, it happened to me today when I inadvertently (that&#8217;s a synonym for &#8220;stupidly&#8221;, right?) wrote over this exact data set.<\/p>\n<p>\/* Generated Code (IMPORT) *\/<br \/>\n\/* Source File: az_pretest.xlsx *\/<br \/>\n\/* Source Path: \/home\/annmaria.demars\/data_analysis_examples\/data2017 *\/<br \/>\n\/* Code generated on: 7\/31\/17, 6:09 PM *\/<\/p>\n<p>%web_drop_table(MYDATA.aztech_pre);<br \/>\nFILENAME REFFILE &#8216;\/home\/annmaria.demars\/data_analysis_examples\/data2017\/az_pretest.xlsx&#8217;;<\/p>\n<p>PROC IMPORT DATAFILE=REFFILE<br \/>\nDBMS=XLSX<br \/>\nOUT=MYDATA.aztech_pre;<br \/>\nGETNAMES=YES;<br \/>\nRUN;<\/p>\n<p>PROC CONTENTS DATA=MYDATA.aztech_pre; RUN;<br \/>\n%web_open_table(MYDATA.aztech_pre);<br \/>\nrun;<\/p>\n<p>Okay, there you go. With a few clicks, your Excel file is accessible in SAS Studio as a SAS data set and you have a copy of the code that did it.<\/p>\n<p>Next post we&#8217;ll start whipping that data into shape.<\/p>\n<p><a href=\"http:\/\/www.7generationgames.com\/buy\/\">When I am not writing about SAS, I&#8217;m making games that teach math, social studies and language.<\/a><\/p>\n<p><a href=\"http:\/\/www.7generationgames.com\/buy\/\">Check them out.<\/a><\/p>\n<p><a href=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2017\/06\/Screen-Shot-2016-05-03-at-2.44.33-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5428\" src=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2017\/06\/Screen-Shot-2016-05-03-at-2.44.33-PM.png\" alt=\"screen shots from our games\" width=\"658\" height=\"275\" srcset=\"https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2017\/06\/Screen-Shot-2016-05-03-at-2.44.33-PM.png 658w, https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2017\/06\/Screen-Shot-2016-05-03-at-2.44.33-PM-300x125.png 300w\" sizes=\"auto, (max-width: 658px) 100vw, 658px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A while back, I wrote a post on getting your Excel data into SAS Studio the quick and easy way. However, \u00a0I hear you saying, What about ME? What about MY needs? What if I don&#8217;t want my data written to the working directory? What if my file has the names at the top and&#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-5453","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\/5453","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=5453"}],"version-history":[{"count":3,"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/posts\/5453\/revisions"}],"predecessor-version":[{"id":5472,"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/posts\/5453\/revisions\/5472"}],"wp:attachment":[{"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/media?parent=5453"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/categories?post=5453"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/tags?post=5453"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}