data have;
input Age $ Race $ Ethnicity $Gender $ DATE1: ddmmyy10. Class ;
FORMAT DATE1 MMDDYY10.;
datalines;
10 W C . 02/01/2017 1
. W C M 03/04/2015 2
. W C F 01/01/2016 2
;
run;
The final table should look like this but I want to be able to filter this output by date (year, qtr, month) and class:
Missing Not Missing Total year Class
Age 2 1 3
Race 0 3 3
Ethnicity 0 3 3
Gender 1 2 3
I tried this code:
*create format for missing; proc format ; value $ missfmt ' '="Missing" other="Not Missing"; value nmissfmt .="Missing" other="Not Missing"; run; /* Created "Year" variable using teh date field and used that in proc freq:*/ *Proc freq to count missing/non missing; ods table onewayfreqs=temp; proc freq data=class; table _all_ / missing; format _numeric_ nmissfmt. _character_ $missfmt.;
But I dont know how can I format the output by variables e.g. (date (year, qtr, month) and class).
by year class; run; *Format output; data want; length variable $32. variable_value $50.; set temp; Variable=scan(table, 2); Variable_Value=strip(trim(vvaluex(variable))); keep variable variable_value frequency percent cum:; label variable='Variable' variable_value='Variable Value'; run;
Thank you
I understand your problem and I know what you want, I just don't want to code it for you.
Feel free to wait for someone else, but the change is literally less than 65 characters.
If you look at the output data set from PROC FREQ and read through the last DATA step I think you'll see clearly where you need to change the code.
That's the answer to the previous question, please show what you've done to answer this question.
@AZIQ1 wrote:
Thank you,
I tried to sort the data by class and used 'by' statement. Edited proc freq to show what I did.
Best
And did that work? What's the issue with the code now?
I understand your problem and I know what you want, I just don't want to code it for you.
Feel free to wait for someone else, but the change is literally less than 65 characters.
If you look at the output data set from PROC FREQ and read through the last DATA step I think you'll see clearly where you need to change the code.
Did you get it working?
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.