Hi,
'DischargeDispositionkey' variable was initially numeric
i am trying to apply the below formats to the 'DischargeDispositionkey' variable and after applying I want the DISP variable created to remain numeric with a lenght of 3.
To my surprise when i use DISP=put(DischargeDispositionkey,dispkey.); I am getting the result but DISP is now a charecter variable....How can that happen ?even after I wrote a numeric format(without quotes and without $sign in front of the format name???
Secondly, it throws an error if itry to use
DISP=input(DischargeDispositionkey,dispkey.);
Please suggest?
proc format;
value dispkey
0,2,13,15,24,27,41,54,55,60,61,65,72,75,76,87,99,100,101,104,110,115,121,127=1
3,6,10,12,16,26,58,59,62,73,77,80,84,86,90,98,105,108,111,116,119,122=2
4,31,45,78,106,117=3
5,47,79,96,107,118=4
14,18,19,20,21,22,23,30,32,33,34,36,38,39,40,44,48,49,51,52,53,56,74,88,92,93,94,95,97,102,103,112,113,114,123,124,125,126=5
7,9,17,25,28,29,37,42,43,50,81,83,91,109,120=6
8,35,46,82=7
11,57,63,64,66,67,68,69,70,71,85,89=20
;
run;
DISP=put(DischargeDispositionkey,dispkey.);
DISP=input(put(DischargeDispositionkey,dispkey.),best.);
OR make an informat
proc format;
invalue dispkey
0,2,13,15,24,27,41,54,55,60,61,65,72,75,76,87,99,100,101,104,110,115,121,127=1
3,6,10,12,16,26,58,59,62,73,77,80,84,86,90,98,105,108,111,116,119,122=2
4,31,45,78,106,117=3
5,47,79,96,107,118=4
14,18,19,20,21,22,23,30,32,33,34,36,38,39,40,44,48,49,51,52,53,56,74,88,92,93,94,95,97,102,103,112,113,114,123,124,125,126=5
7,9,17,25,28,29,37,42,43,50,81,83,91,109,120=6
8,35,46,82=7
11,57,63,64,66,67,68,69,70,71,85,89=20
;
run;
before using:
DISP=input(DischargeDispositionkey,dispkey.);
Put always creates a character result, input can create a numerical result.
DISP=input(put(DischargeDispositionkey,dispkey.),best.);
OR make an informat
proc format;
invalue dispkey
0,2,13,15,24,27,41,54,55,60,61,65,72,75,76,87,99,100,101,104,110,115,121,127=1
3,6,10,12,16,26,58,59,62,73,77,80,84,86,90,98,105,108,111,116,119,122=2
4,31,45,78,106,117=3
5,47,79,96,107,118=4
14,18,19,20,21,22,23,30,32,33,34,36,38,39,40,44,48,49,51,52,53,56,74,88,92,93,94,95,97,102,103,112,113,114,123,124,125,126=5
7,9,17,25,28,29,37,42,43,50,81,83,91,109,120=6
8,35,46,82=7
11,57,63,64,66,67,68,69,70,71,85,89=20
;
run;
before using:
DISP=input(DischargeDispositionkey,dispkey.);
Thanks for the reply.
Also is it incorrect to put in quotes while writing formats for numeric variables????
OR it doesn't matter if we put or not
/*QUOTED VALUES*/
proc format;
invalue dispkey
'0','2','13','15','24','27'=1
run;
Vs.
/*NO QUOTES */
proc format;
invalue dispkey
0,2,13,15,24,27=1
run;
Use QUOTED when DischargeDispositionkey is character .
whereas , NO QUOTED for numeric .
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.