As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.


Here are some tips for How to share your SAS knowledge with your professional network.


Difference between revisions of "Tip of the Day:May 5"

From sasCommunity
Jump to: navigation, search
(Scheduled Detailed Directory Listing from PROC CONTENTS)
(Scheduled Multiple Dataset Options)
 
Line 5: Line 5:
 
sasCommunity Tip of the Day
 
sasCommunity Tip of the Day
 
</h1><div style="padding:10px;">
 
</h1><div style="padding:10px;">
{{Tips:Detailed Directory Listing from PROC CONTENTS}}
+
{{Tips:Multiple Dataset Options}}
 
<div style="width:100%"><hr></div>
 
<div style="width:100%"><hr></div>
Feel free to [[Tips Talk:Detailed Directory Listing from PROC CONTENTS|comment]] on this tip.
+
Feel free to [[Tips Talk:Multiple Dataset Options|comment]] on this tip.
 
</div>
 
</div>
 
</td></tr>
 
</td></tr>

Latest revision as of 21:15, 29 April 2011

sasCommunity Tip of the Day

When multiple dataset options are applied to a single statement, then the order of execution matters. The rule of thumb is that they are executed according to the lexicographical(alphabetical) order of their names. That is, a drop option is executed before a keep, and a keep before a rename. A logical consequence is that you have to use the old (before being renamed) variable names in your keep and drop options. Another is that you cannot keep a variable, if dropped.

Now, given also that the variable number is decided by the order of first-appearance in the data step, can you guess the output of the code snippet below? The answer can be found in the discussion page.

data one;
    set sashelp.class(rename=(name=eman) keep=age sex name drop=age);
run;
 
/* check */
proc contents data=one varnum;
run;

Submitted by Chang Y. Chung. Contact me at my Discussion Page.

Using Dataset Options (9.2)



Feel free to comment on this tip.


Prior tip - Next tip - Random Tip

Submit a Tip