Posts

Showing posts from May, 2010

Sending the LOG and OUTPUT from PC SAS to a seperate file

Image
Here is how to direct the SAS LOG file and or SAS Output  to a seperate file. Approach 1: Using Display Manager Statements; filename log ' C:\temp\logfile.log '; filename out ' C:\temp\output.lst '; *Select only male students and age less than 16; proc sql; create table males as select age, height, weight from sashelp.class where sex=' M ' and age lt 16  order by age; quit; *Get the descriptive statistics for height variable by age; proc means data =males ; by age; var height; output out =htstats mean =mean n =n std =sd median =med min =min max =max; run; DM ' OUT;FILE OUT REP; '; DM ' LOG;FILE LOG REP; '; Information about Display Manager Commands: DEXPORT and DIMPORT: DISPLAY MANAGER commands used to IMPORT and EXPORT the Tab delimited (Excel and .CSV) files; SAS Display Manager Commands Approach 2: Using Proc PRINTTO procedure; Refer:  How to save the log file or what is PROC PRINTTO procedur...

Random Sample Selection

Image
Last week my manager asked me to randomly pick 10%observations from a large data set and then create a listing so that the Data management programmers can QC the data. I want to share some thoughts here … how easy and simple to do random sampling. Approach 1: Data step Approach: In this approach, the observations are shuffled using the RANUNI function which assigns a random number to each observation. Step1 : Generating the Random Vector (shuffling) using the RANUNI function; The RANUNI function generates a random number from a continuous uniform distribution (the interval (0, 1). Step2 : After assigning a random number to each record, the records can then be sorted in ascending or descending order of the random numbers.; data randsamp ; input patno @@; random= RANUNI ( -1 ); * RANUNI function to assign a random number to each record.; * Here the seed is negative integer (-1) so the results are not replicable.; cards; 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 2...