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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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