BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi all,

I am using Proc Freq for frequency count and I have different variables in a dataset for which I count frequency and then stack all the dataset created from Proc Freq result to create final dataset from which I can generate table using Proc Report. Sometimes some of the variables have no frequency count and I get empty dataset but I still want that to be displayed as 0 in final table. Proc Freq gives empty dataset if the frequency count is 0. What can I do in this case? Right now, I am doing hard coding using Proc Sql to insert a row which shows 0 as frequency count for that variable. I think there should be alternate for this.

Jigar.
3 REPLIES 3
Olivier
Pyrite | Level 9
If I understand well, you want a line even if your variable is only made of missing values.
Maybe just adding a MISSING option to the TABLE would fix your problem.

Olivier
Olivier
Pyrite | Level 9
Maybe something interesting in that little program :

DATA work.test (DROP = id) ;
DO id = 1 TO 10 ;
allMiss = . ;
allNMiss = MOD(id,3) ;
IF RANUNI(0)<.3 THEN partMiss = . ;
ELSE partMiss = id ;
OUTPUT ;
END ;
RUN ;
ODS EXCLUDE ALL ;
PROC TABULATE DATA = work.test OUT = work.frequencies ;
CLASS allMiss allNMiss partMiss /
Olivier
Pyrite | Level 9
MISSING ;
TABLE allMiss allNMiss partMiss ;
RUN ;
ODS SELECT ALL ;
DATA work.frequencies (KEEP = varName value N) ;
SET work.frequencies ;
ARRAY values allMiss allNMiss partMiss ;
i = INDEX(_type_, '1');
value = values(i) ;
varname = VNAME(values(i)) ;
RUN ;

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
  • 3 replies
  • 1138 views
  • 0 likes
  • 2 in conversation