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 ;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1854 views
  • 0 likes
  • 2 in conversation