BookmarkSubscribeRSS Feed
dsky227
Calcite | Level 5

I have a data set with two text variables (tvar1 & tvar2) and one numeric variable (nvar)

I want to create these tables

                                  tvar2 is missing    tvar2 is not missing

tvar1 is missing                xx                           xx

tvar1 is not missing         xx                             xx

 

                 tvar1 is missing     tvar2 is not missing

nvar (values)

I can't figure it out.  

If I run 

   proc format;

      value missing_ind .='missing' other='not missing';

run;

  then what do I do?  

3 REPLIES 3
PaigeMiller
Diamond | Level 26

 The format makes it more readable, but PROC FREQ still ignores missing values, regardless of how it is formatted.

 

You need to use the MISSING option in the TABLES statement to tell PROC FREQ to count the missing values https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=procstat&docsetTarget=pro...

--
Paige Miller
Rick_SAS
SAS Super FREQ

You use PROC FREQ, as shown in the examples in this article.

For the first table, you can use 

table tvar1*tvar2;

 

I'm not sure what you intend for the second table. For the columns, is there a typo? Do you mean 

tvar1 is missing     tvar1 is not missing  

Do you want the count for each column for each discrete value of the numeric variable?

 

As always, sample data will make the questions clearer and the answers easier to describe.

 

ballardw
Super User

@dsky227 wrote:

I have a data set with two text variables (tvar1 & tvar2) and one numeric variable (nvar)

I want to create these tables

                                  tvar2 is missing    tvar2 is not missing

tvar1 is missing                xx                           xx

tvar1 is not missing         xx                             xx

 

                 tvar1 is missing     tvar2 is not missing

nvar (values)

I can't figure it out.  

If I run 

   proc format;

      value missing_ind .='missing' other='not missing';

run;

  then what do I do?  


Your format is only defined for NUMERIC values. You would need to make a similar format for character variables.

proc format;
value $missing_ind 
' '='missing' 
other='not missing'
;

run;

The format can have the similar name because the $ means it is only for Character variables.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 615 views
  • 1 like
  • 4 in conversation