BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
EmilyAV
Calcite | Level 5

I have a dataset organized as follows:

data have;

infile id group1 $ group2 $;

datalines

1 a1 b1

2 a1 b2

3 a2 b1

;

run;

 

Group1 contains 50 categories with no missing values.

Group2 contains 2 categories and some missing values.

I need to generate a dataset that includes counts for all combinations of group 1 and group 2, including an observation of 0 when group 2 has a missing value.

 

I've been using proc freq as follows:

 

proc freq data=have;
tables group1*group2 / crosslist missing out=want;
run;

 

This code displays the results that I'm looking for, but the generated dataset does not include observations where group1*group2 counts are missing. The result is not changed by using the missprint option. Is there another approach I might try?

 

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Use the SPARSE option in the TABLES statement of PROC FREQ

--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

Use the SPARSE option in the TABLES statement of PROC FREQ

--
Paige Miller

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 586 views
  • 1 like
  • 2 in conversation