- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi!
I'm formatting a variable that is discrete with options from 0 to 10. The variable is a scale on how much the respondent trusts politics with 0 being no trust at all and 10 as complete trust. When I give these values as a format, the 10 does not show up in the frequency table because no respondents answered 10... This is an an issue because then you dont see where the scale ends, is there a way to include this category in the frequency table anyway and just have a 0 as frequency?
thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You talk about frequency table in the title. Do you mean you are using PROC FREQ??? It would help if you could state clearly how you are doing this. Can you show us the code you are using?
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Sadly, PROC FREQ doesn't have an easy option for this. If you switch to PROC TABULATE, it has a preloadfmt option that could be used.
For PROC FREQ, see the approach in this answer:
https://communities.sas.com/t5/SAS-Procedures/PROC-FREQ-Include-Zero-Counts/td-p/325505
Also described here:
Next up: Troy Martin Hughes presents Calling Open-Source Python Functions within SAS PROC FCMP: A Google Maps API Geocoding Adventure on Wednesday April 23.
Register now at https://www.basug.org/events.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
PROC FREQ with the ZEROS option in the WEIGHT statement can do this.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@PaigeMiller wrote:
PROC FREQ with the ZEROS option in the WEIGHT statement can do this.
Indeed, and that's the approach shown in the answer I linked to. But without PRELOADFMT, it typically requires an extra step to add in the records with zero weight. So there is no 'easy' option you can add to PROC FREQ to say 'give me a table with all the categories defined in a format.'
Next up: Troy Martin Hughes presents Calling Open-Source Python Functions within SAS PROC FCMP: A Google Maps API Geocoding Adventure on Wednesday April 23.
Register now at https://www.basug.org/events.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Extra step yes, but to me it is not a burdensome requirement.
Example: using SASHELP.CLASS, create a frequency table of ages that includes age 17 (there are zero age 17s in the data set)
data class;
set sashelp.class end=eof;
weight=1;
output;
if eof then do;
age=17;
weight=0;
output;
end;
run;
proc freq data=class;
tables age;
weight weight/zeros;
run;
Paige Miller