BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
AZIQ1
Quartz | Level 8

 

 

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.;
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;
But I dont know how can I format the output by variables e.g. (date (year, qtr, month) and class).

Thank you

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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. 

 

 

View solution in original post

7 REPLIES 7
Reeza
Super User

That's the answer to the previous question, please show what you've done to answer this question.

AZIQ1
Quartz | Level 8
Thank you,
I tried to sort the data by class and used 'by' statement. Edited proc freq to show what I did.
Best
Reeza
Super User

@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?

 

 

AZIQ1
Quartz | Level 8
I think I am having trouble explaining it correctly. My apologies.
The code isn't working means its not giving me the output that I want.
I want the output to show frequencies of missing and non missing by Year and Class.
The output should look like this:


year class missing nonmissing total
Thank you

Reeza
Super User

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. 

 

 

AZIQ1
Quartz | Level 8
Thank you.
Reeza
Super User

Did you get it working? 

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 1046 views
  • 1 like
  • 2 in conversation