BookmarkSubscribeRSS Feed

Hi,

 

I have created the PROC Format below which i thought would capture all scenarios but my output is getting a value for '.'

 

Any idea why please

 

value ppd
LOW - 0 = "UTD"
0 <-1 = "LT 1 PPD"
1 <-2 = "1 PPD"
2 <-3 = "2 PPD"
3 <- HIGH = "3+ PPD";

4 REPLIES 4
Kurt_Bremser
Super User

You either need to name a specific label for missing values

. = 'Missing'

or use OTHER as range to "catch" all values that have not been covered by your ranges:

OTHER = 'Everything else'

 

Thanks, but I would have thought that the ranges specified would cover them all off so I wouldn't expect any missing values.

Kurt_Bremser
Super User

Although a missing value is considered smaller than any other numeric value in comparisons, it is not included in a range that starts with low. That only covers non-missing values. Your intention is probably met best by doing this:

data have;
input inval;
cards;
.
-1
0
1
2
3
4
;
run;

proc format library=work;
value ppd
  .,LOW - 0 = "UTD"
  0 <- 1 = "LT 1 PPD"
  1 <- 2 = "1 PPD"
  2 <- 3 = "2 PPD"
  3 <- HIGH = "3+ PPD"
;
run;

data want;
set have;
outval = put(inval,ppd.);
run;

proc print noobs;
run;

Output:

inval    outval

   .     UTD     
  -1     UTD     
   0     UTD     
   1     LT 1 PPD
   2     1 PPD   
   3     2 PPD   
   4     3+ PPD  

Thank you for your help, that worked! 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 4 replies
  • 26563 views
  • 1 like
  • 2 in conversation