The SAS Output Delivery System and reporting techniques

Empty Dataset from Proc Freq

Reply
N/A
Posts: 0

Empty Dataset from Proc Freq

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.
Super Contributor
Posts: 260

Re: Empty Dataset from Proc Freq

Posted in reply to deleted_user
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
Super Contributor
Posts: 260

Re: Empty Dataset from Proc Freq

Posted in reply to deleted_user
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 /
Super Contributor
Posts: 260

Re: Empty Dataset from Proc Freq

Posted in reply to deleted_user
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 ;
Ask a Question
Discussion stats
  • 3 replies
  • 197 views
  • 0 likes
  • 2 in conversation