{"id":4238,"date":"2014-09-02T17:34:12","date_gmt":"2014-09-02T22:34:12","guid":{"rendered":"http:\/\/www.thejuliagroup.com\/blog\/?p=4238"},"modified":"2014-09-02T17:41:12","modified_gmt":"2014-09-02T22:41:12","slug":"another-of-my-favorite-procs-proc-datasets","status":"publish","type":"post","link":"https:\/\/www.thejuliagroup.com\/blog\/another-of-my-favorite-procs-proc-datasets\/","title":{"rendered":"Another of my favorite procs: PROC DATASETS"},"content":{"rendered":"<p>I&#8217;m just heading off to the Western Users of SAS Software meeting that starts tomorrow.\u00a0 After the keynote, during which I have promised not to swear even once, I&#8217;m doing a SAS Essentials talk on Thursday, where I teach students 10 basic steps that allow them to complete an entire annual report project.<\/p>\n<p>One of these is PROC DATASETS.\u00a0 It is used twice in the project. First, they get a list of all of the datasets in the directory. We&#8217;re using SAS Studio which runs on the SAS server. Since students neither have access to issue Unix commands directly nor do they know any most likely, we use PROC DATASETS.<br \/>\n<code><br \/>\nlibname mydata\u00a0 \"\/courses\/u_mine.edu1\/i_1234\/c_7890\/wuss14\/\";<br \/>\nproc datasets library= mydata ;<\/code><\/p>\n<p>This gives me the output below.<\/p>\n<table>\n<thead>\n<tr>\n<td width=\"44\"><strong>#<\/strong><\/td>\n<td width=\"113\"><strong>Name<\/strong><\/td>\n<td width=\"68\"><strong>Member Type<\/strong><\/td>\n<td width=\"63\"><strong>File Size<\/strong><\/td>\n<td width=\"108\"><strong>Last Modified<\/strong><\/td>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td width=\"44\"><strong>1<\/strong><\/td>\n<td width=\"113\">SLPOST_SCORED<\/td>\n<td width=\"68\">DATA<\/td>\n<td width=\"63\">208896<\/td>\n<td width=\"108\">26Jun14:04:00:40<\/td>\n<\/tr>\n<tr>\n<td width=\"44\"><strong>2<\/strong><\/td>\n<td width=\"113\">SLPRE_SCORED<\/td>\n<td width=\"68\">DATA<\/td>\n<td width=\"63\">487424<\/td>\n<td width=\"108\">26Jun14:04:00:41<\/td>\n<\/tr>\n<tr>\n<td width=\"44\"><strong>3<\/strong><\/td>\n<td width=\"113\">SL_ANSWERS<\/td>\n<td width=\"68\">DATA<\/td>\n<td width=\"63\">619520<\/td>\n<td width=\"108\">26Jun14:03:59:42<\/td>\n<\/tr>\n<tr>\n<td width=\"44\"><strong>4<\/strong><\/td>\n<td width=\"113\">SL_PRE_POST<\/td>\n<td width=\"68\">DATA<\/td>\n<td width=\"63\">196608<\/td>\n<td width=\"108\">26Jun14:04:00:03<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>Once we have cleaned up the data in every data set, we are not quite ready to start merging them together. A common problem is that data sets have different names, lengths or types for the same variable. You\u2019d be wise to check the variable names, types and lengths of all the variables.\u00a0 So, here is where we use PROC DATASETS a second time.<br \/>\n<code><br \/>\nproc datasets library= work ;<br \/>\ncontents data = _all_ ;<\/code><\/p>\n<p>This time, we added another statement. The \u201ccontents data = _all_ \u201c will print the contents of all of the data sets. In perusing the contents, I see that grade is entered as character data in one \u2013 5th, 4th and so on, while it is numeric data in another. This is the sort of thing you never run into in \u201cback of the textbook\u201d data, but that shows up often in real life.<\/p>\n<p>Those are two super simple steps that allow you to do useful things.<\/p>\n<p>You can do more with PROC DATASETS &#8211; append, compare &#8211; but my plane is boarding so more about that some other time.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m just heading off to the Western Users of SAS Software meeting that starts tomorrow.\u00a0 After the keynote, during which I have promised not to swear even once, I&#8217;m doing a SAS Essentials talk on Thursday, where I teach students 10 basic steps that allow them to complete an entire annual report project. One of&#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-4238","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\/4238","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=4238"}],"version-history":[{"count":4,"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/posts\/4238\/revisions"}],"predecessor-version":[{"id":4242,"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/posts\/4238\/revisions\/4242"}],"wp:attachment":[{"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/media?parent=4238"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/categories?post=4238"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/tags?post=4238"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}