Help using Base SAS procedures

Proc Freq and null/zero frequencies

Accepted Solution Solved
Reply
Regular Contributor
Posts: 216
Accepted Solution

Proc Freq and null/zero frequencies

Hi

I have a data set that I run several frequencies and simple percents on which lead to an output similar to the below example file. One of the variables that I include in the many frequencies is an Exit Month time frame. For the Exit Month variable, I included a check for a 0 month option, but there are no values for 0 in the entire data set. Is there any way to include a 0 Exit Month value in the output from these SAS routines equaling a count of 0?

http://www.nycourts.gov/surveys/cwcip/procFreqOutput.zip

Below is one of the many frequencies that I run on this data set:

proc freq data=s1ageshort noprint;

  tables startyear*exit*agecat4*exitMonthCategory/out=s1ageshorttest sparse;

run;

Paul


Accepted Solutions
Solution
‎12-14-2012 04:49 PM
SAS Super FREQ
Posts: 8,868

Re: Proc Freq and null/zero frequencies

Posted in reply to data_null__

Hi:

PROC REPORT and TABULATE also support PRELOADFMT (with TABULATE, you need PRINTMISS and with REPORT, you need COMPLETEROWS option). TABULATE and MEANS will both use CLASSDATA. Check the documentation for which one applies to your situation.

  By way of explanation, PROC FREQ, with the SPARSE option will put a row for F age 16 into the FREQ output for SASHELP.CLASS because AGE 16 is in the data, but only for M age 16. However, AGE 10 is NOT in the dataset -- at all -- so the SPARSE option will not put AGE10 in the output. That is the kind of thing that REPORT and TABULATE and MEANS/SUMMARY will do.

cynthia

View solution in original post


All Replies
Respected Advisor
Posts: 3,799

Re: Proc Freq and null/zero frequencies

You need a PROC that allows the creation of something from nothing.  SUMMARY/MEANS and TABULATE are two.  For SUMMARY/MEANS look at documentation concerning the CLASSDATA option and or PRELOADFMT.  You can get to the same place by either method.

Solution
‎12-14-2012 04:49 PM
SAS Super FREQ
Posts: 8,868

Re: Proc Freq and null/zero frequencies

Posted in reply to data_null__

Hi:

PROC REPORT and TABULATE also support PRELOADFMT (with TABULATE, you need PRINTMISS and with REPORT, you need COMPLETEROWS option). TABULATE and MEANS will both use CLASSDATA. Check the documentation for which one applies to your situation.

  By way of explanation, PROC FREQ, with the SPARSE option will put a row for F age 16 into the FREQ output for SASHELP.CLASS because AGE 16 is in the data, but only for M age 16. However, AGE 10 is NOT in the dataset -- at all -- so the SPARSE option will not put AGE10 in the output. That is the kind of thing that REPORT and TABULATE and MEANS/SUMMARY will do.

cynthia

Regular Contributor
Posts: 216

Re: Proc Freq and null/zero frequencies

Posted in reply to Cynthia_sas

Thanks Cynthia. That explains it then.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 411 views
  • 3 likes
  • 3 in conversation