Author

Jim Simon
RSS
Principal Technical Training Consultant

Jim Simon is a principal instructor and course developer for SAS Education. Jim has a bachelor's degree from UCLA and a master's degree from California State University at Northridge. Prior to joining the SAS Irvine office in 1988, Jim was an instructor at Ventura College and a SAS programmer at The Medstat Group in Santa Barbara. Jim's areas of specialization include the DATA step, application development, web enablement, and the SAS macro language. A native of Southern California, Jim enjoys anything in the warm California sun. On weekends, Jim loves jumping in his Corvette, turning up the stereo, and cruising Pacific Coast Highway, top down, South to Laguna Beach or North to his old home town, Santa Barbara.

Learn SAS | Programming Tips
Jim Simon 0
How to format a macro variable

Would you like to format your macro variables? Easy!  Just use the %FORMAT function, like this: What?! You never heard of the %FORMAT function? Of course not, cuz it doesn't exist! No problem. Just create it, like this: %macro format(value,format); %if %datatyp(&value)=CHAR %then %sysfunc(putc(&value,&format)); %else %left(%qsysfunc(putn(&value,&format))); %mend format; The %FORMAT

Learn SAS
Jim Simon 0
Random Sampling: What's Efficient?

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,

Learn SAS
Jim Simon 0
Reading Hierarchical Data - Part 3

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

Learn SAS
Jim Simon 0
Reading hierarchical data - Part 2

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

Learn SAS
Jim Simon 0
Reading hierarchical data - Part 1

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

Learn SAS
Jim Simon 0
DATA STEP text file tricks

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

Learn SAS
Jim Simon 0
Weird PROC FREQ trick

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;

Learn SAS
Jim Simon 0
Dataset too big for PROC PRINT?

Dataset too big for PROC PRINT? One weird trick solves your problem! proc print data=bigdata (obs=10); run; The OBS= dataset option specifies the last observation to process from an input dataset. In the above example, regardless of dataset size, only the first 10 observations are printed; an easy way to

Learn SAS
Jim Simon 0
Importing CSV files into SAS datasets

Sometimes, your first impulse may not be correct, like trading in your practical sedan for a hot 2-seater.  Other times, your first impulse is perfect, as in the examples below. Suppose the automobile data you wish to analyze resides in a CSV file.  Naturally, your first impulse is to import

Learn SAS
Jim Simon 0
Time to trade in your jalopy macro?

Suppose you have an old jalopy that's perfectly reliable.  Your jalopy gets you where you wanna go: no frills; no drama. Do you trade your old wheels in for a racecar that accelerates like crazy and corners like it's on rails? Or stick with what's old and comfortable?   Your choice