Hello,
i was asked to print obervations with 5 highest frequencies from a big dataset. i did this to order the frequency in descending order.
PROC FREQ DATA = WEEK6.THCICSAMP ORDER = FREQ;
TABLES ADMITTING_DIAG PRINC_DIAG_CODE;
RUN;
but i want to print , so i tried to create a new data set with only my frequencies for the 2 variables, sort by decreasing frequencies and use proc print :
PROC FREQ DATA = WEEK6.THCICSAMP STACKODSOUTPUT NOPRINT;
TABLES ADMITTING_DIAG PRINC_DIAG_CODE /OUT = WEEK6.FREQDIAG;
RUN;
i noticed that the new data set week6.freqdiaq i created has only one of the variable, PRINC_DIAG_CODE. how can i get all my variables out into the new dataset please?
Thank you so much, I wanted to do it all in one step.
You could use ODS.
PROC FREQ DATA = WEEK6.THCICSAMP ORDER = FREQ;
TABLES ADMITTING_DIAG PRINC_DIAG_CODE;
ods output onewayfreqs=out;
RUN;
When I wanted to print out the observations though, I noticed the PRINC_DIAG_CODE variable is blank
the variables in the two dataset i have created have similar names, so if i use merge command in my datastep, one will overwrite the other, do i have to rename the observations? they both have count and percentage of frequency count in common as variable names. do i also have to create a common variable like ID number to merge them ?
thanks
yes. you need rename it before set them all.
proc freq data=sashelp.class noprint ; table weight/out=weight(rename=(weight=vname)); table age/out=age(rename=(age=vname)); run; data want; set weight age indsname=dsn; dsname=dsn; run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.