hello I have a variable which is in character format for e.g. var PPP
PPP
400
401
402
403
404
405
406
407
408
409
410
I want to take everything from 400 to 405 and make it 405 and for 406 to 410 make it 410. This is what I tried
proc format;
value pppfmt
400 -< 405 = 405
406 -< 410 = 410;
run;
data table1;
set table;
format ppp pppfmt.;
run;
but I get an error in the data step saying the format could not be uploaded, I think it has to do with the fact I am using the technique used for formatting numbers on characters.
Thanks in advance!
You need a character format to format character variables.
proc format;
value $pppfmt
'400'-'405'='405'
'406'-'410'='410'
;
quit;
If they're numbers you could just round it?
PPP_CAT = round(input(PPP, 8.) +2.5, 5);
Adding 2.5 ensures it will always round correctly to the value of interest. Make sure to test the boundaries though, ie 400, 405.
@haider_imam wrote:
hello I have a variable which is in character format for e.g. var PPP
PPP
400
401
402
403
404
405
406
407
408
409
410
I want to take everything from 400 to 405 and make it 405 and for 406 to 410 make it 410. This is what I tried
proc format;
value pppfmt
400 -< 405 = 405
406 -< 410 = 410;
run;
data table1;
set table;
format ppp pppfmt.;
run;
but I get an error in the data step saying the format could not be uploaded, I think it has to do with the fact I am using the technique used for formatting numbers on characters.
Thanks in advance!
You need a character format to format character variables.
proc format;
value $pppfmt
'400'-'405'='405'
'406'-'410'='410'
;
quit;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.