Jim Simon

11月 112017
 

Here's a Proc Print trick for grouped data. Suppose your data is divided into groups, such as males and females. You could sort by the grouping variable before printing, like this: Suppose you want to better emphasize the groups. You could add a BY statement, like this: OK, but, personally, [...]

The post Simple Proc Print trick for grouped data appeared first on SAS Learning Post.

10月 252017
 

Suppose you want a list of car manufacturers from the CARS dataset. Easy!  Call the %CHARLIST macro from a %PUT statement, like this: The CHARLIST macro generates a list of unique values of a selected variable from a selected dataset. So does PROC FREQ. But, if you don't need statistics, the CHARLIST [...]

The post Finding your Dream Car with a little macro magic appeared first on SAS Learning Post.

10月 172017
 

Would you like to format your macro variables in SAS? Good news. It's easy!  Just use the %FORMAT function, like this: %let x=1111; Log %put %format(&x,dollar11.); $1,111 %put %format(&x,roman.); MCXI %put %format(&x,worddate.); January 16, 1963   %let today=%sysfunc(today()); %put %format(&today,worddate.); October 13, 2017   %put %format(Macro,$3.); Mac What?!  You never [...]

The post How to format a macro variable appeared first on SAS Learning Post.

1月 242017
 

In a previous blog, Random Sampling: What's Efficient?, I discussed the efficiency of various techniques for selecting a simple random sample from a large SAS dataset.  PROC SURVEYSELECT easily does the job: proc surveyselect data=large out=sample method=srs /* simple random sample */ rate=.01; /* 1% sample rate */ run; Note: […]

The post Stratified random sample: What's efficient? appeared first on SAS Learning Post.

9月 042015
 

Suppose you wish to select a random sample from a large SAS dataset.  No problem. The PROC SURVEYSELECT step below randomly selects a 2 percent sample: proc surveyselect data=large out=sample method=srs /* simple random sample */ n=1000000; /* sample size */ run; Do you have a SAS/STAT license?   If not, […]

The post Random Sampling: What's Efficient? appeared first on SAS Learning Post.

9月 012015
 

This post is the third and final in a series that illustrates three different solutions to "flattening" hierarchical data.  Don't forget to catch up with Part 1 and Part 2. Solution 2, from my previous post, created one observation per header record, with detail data in a wide format, like […]

The post Reading Hierarchical Data - Part 3 appeared first on The SAS Training Post.

8月 282015
 

This post is the second in a series that illustrates three different solutions to "flattening" hierarchical data. Solution 1, from my previous post, created one observation per header record, summarizing the detail data with a COUNT variable, like this: Summary Approach: One observation per header record   Obs Family Count […]

The post Reading hierarchical data - Part 2 appeared first on The SAS Training Post.

8月 262015
 

A family and its members represent a simple hierarchy.  For example, the Jones family has four members: A text file might represent this hierarchy with family records followed by family members' records, like this:   The PROC FORMAT step below defines the codes in Column 1: proc format; value $type […]

The post Reading hierarchical data - Part 1 appeared first on The SAS Training Post.

6月 082015
 

When reading a text file (common extensions: TXT, DAT; or, for the adventurous: HTML) with the DATA STEP, you should always view several lines from the text file, and compare to the record layout, before completing the INPUT statement.  There are many ways to view a text file.  I use […]

The post DATA STEP text file tricks appeared first on The SAS Training Post.

6月 042015
 

Default PROC FREQ output looks like this: Suppose you don't want the two cumulative statistic columns above.  No problem.  Those can be suppressed with the NOCUM option on the TABLE statement, like this: proc freq data=sashelp.shoes; table product / nocum; run; Now your output looks like this, but you lose […]

The post Weird PROC FREQ trick appeared first on The SAS Training Post.