proc tabulate data=PlaceBaseSet missing out=Place;
class location age academic_period;
table location*age all*age, academic_period;
run;
data Place; set Place;
if n=. then n = 0; /* row does not exist so this does not work*/
run;
proc print data= Place;
In SAS 9.2, I am attempting to convert a dataset to proc tabulate. From tabulate I want to convert it to a tabular dataset. The code for converting from proc tabulate is above. My tabular dataset cannot have missing values. I found that a missing value in a tabulate structure is not included in the resulting tabular data. Is there a way to save nulls in proc tabulate to a value of zero?
PRELOADFMT or CLASSDATA
If you could provide a few rows of data for PlaceBaseSet and the desired final outcome we might be able to help better. Or at least of the starting Place set.
You might need a MISSING option on your class statement. I would not expect anything to be missing from the output of tabulate in this case as tabulate by default excludes any records with missing values for the class variables unless explicitly told to include them in the summary.
proc print displays
1 | 1 | 1 | 201110 | 111 | 1 | 1 | 4621 |
---|---|---|---|---|---|---|---|
2 | 1 | 1 | 201210 | 111 | 1 | 1 | 4758 |
3 | 1 | 1 | 201310 | 111 | 1 | 1 | 4595 |
4 | 1 | 1 | 201410 | 111 | 1 | 1 | 4261 |
5 | 1 | 1 | 201510 | 111 | 1 | 1 | 4155 |
6 | 1 | 2 | 201110 | 111 | 1 | 1 | 5 |
7 | 1 | 2 | 201210 | 111 | 1 | 1 | 4 |
8 | 1 | 2 | 201310 | 111 | 1 | 1 | 4 |
9 | 1 | 2 | 201510 | 111 | 1 | 1 | 9 |
there should be a row between 8 and 9. Apparently "7 really ate 9".
PRELOADFMT or CLASSDATA
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.