hello,
I am trying to convert the ASSEV variables values into numeric values . I created format for that and then used that format , but the numeric variable (AESEVN) values are missing. What wrong I am doing ,could u plz check .
Format and note is below ;
/****************************************/
proc format;
invalue sev
"mild" = 1
"moderate" = 2
"severe" = 3;
run;
data test;
set ae;
aesevn = input(aesev,??sev.);
run;
note is showing into the log:
Spelling counts. "mild" is not "Mild" , which appears in your data.
Try this:
proc format; invalue sev (upcase) "MILD" = 1 "MODERATE" = 2 "SEVERE" = 3; run;
The upcase option will turn the text into upper case before comparing the values in the informat list. So spellings in the source of "mild" "Mild" "mILD" "milD" and other possible typos all use "MILD" for assigning the numeric value.
If your data is clean, then use the proper spelling to begin with. I tend to use the UPCASE option on all my character to numeric informats just because I don't trust my sources (with good reason) to spell things consistently.
@u52766097 wrote:
hello,
I am trying to convert the ASSEV variables values into numeric values . I created format for that and then used that format , but the numeric variable (AESEVN) values are missing. What wrong I am doing ,could u plz check .
Format and note is below ;
/****************************************/
proc format;
invalue sev
"mild" = 1
"moderate" = 2
"severe" = 3;
run;
data test;
set ae;
aesevn = input(aesev,??sev.);
run;
note is showing into the log:
NOTE: Invalid argument to function INPUT at line 71 column 10.usubjid=1001 aestdtc=2021-01-15 aeterm=AE1 aesev=Mild aeser= aediscon= aesevn=. _ERROR_=1 _N_=1NOTE: Invalid argument to function INPUT at line 71 column 10.usubjid=1001 aestdtc=2021-01-25 aeterm=AE1 aesev=Severe aeser= aediscon= aesevn=. _ERROR_=1 _N_=2NOTE: Invalid argument to function INPUT at line 71 column 10.usubjid=1001 aestdtc=2021-01-15 aeterm=AE2 aesev=Mild aeser= aediscon= aesevn=. _ERROR_=1 _N_=3NOTE: Invalid argument to function INPUT at line 71 column 10.usubjid=1001 aestdtc=2021-01-25 aeterm=AE2 aesev=Mild aeser= aediscon= aesevn=. _ERROR_=1 _N_=4NOTE: Invalid argument to function INPUT at line 71 column 10.usubjid=1001 aestdtc=2021-01-15 aeterm=AE3 aesev=Mild aeser= aediscon= aesevn=. _ERROR_=1 _N_=5NOTE: Invalid argument to function INPUT at line 71 column 10.usubjid=1001 aestdtc=2021-01-25 aeterm=AE3 aesev=Mild aeser= aediscon=1 aesevn=. _ERROR_=1 _N_=6Thanks
Spelling counts. "mild" is not "Mild" , which appears in your data.
Try this:
proc format; invalue sev (upcase) "MILD" = 1 "MODERATE" = 2 "SEVERE" = 3; run;
The upcase option will turn the text into upper case before comparing the values in the informat list. So spellings in the source of "mild" "Mild" "mILD" "milD" and other possible typos all use "MILD" for assigning the numeric value.
If your data is clean, then use the proper spelling to begin with. I tend to use the UPCASE option on all my character to numeric informats just because I don't trust my sources (with good reason) to spell things consistently.
@u52766097 wrote:
hello,
I am trying to convert the ASSEV variables values into numeric values . I created format for that and then used that format , but the numeric variable (AESEVN) values are missing. What wrong I am doing ,could u plz check .
Format and note is below ;
/****************************************/
proc format;
invalue sev
"mild" = 1
"moderate" = 2
"severe" = 3;
run;
data test;
set ae;
aesevn = input(aesev,??sev.);
run;
note is showing into the log:
NOTE: Invalid argument to function INPUT at line 71 column 10.usubjid=1001 aestdtc=2021-01-15 aeterm=AE1 aesev=Mild aeser= aediscon= aesevn=. _ERROR_=1 _N_=1NOTE: Invalid argument to function INPUT at line 71 column 10.usubjid=1001 aestdtc=2021-01-25 aeterm=AE1 aesev=Severe aeser= aediscon= aesevn=. _ERROR_=1 _N_=2NOTE: Invalid argument to function INPUT at line 71 column 10.usubjid=1001 aestdtc=2021-01-15 aeterm=AE2 aesev=Mild aeser= aediscon= aesevn=. _ERROR_=1 _N_=3NOTE: Invalid argument to function INPUT at line 71 column 10.usubjid=1001 aestdtc=2021-01-25 aeterm=AE2 aesev=Mild aeser= aediscon= aesevn=. _ERROR_=1 _N_=4NOTE: Invalid argument to function INPUT at line 71 column 10.usubjid=1001 aestdtc=2021-01-15 aeterm=AE3 aesev=Mild aeser= aediscon= aesevn=. _ERROR_=1 _N_=5NOTE: Invalid argument to function INPUT at line 71 column 10.usubjid=1001 aestdtc=2021-01-25 aeterm=AE3 aesev=Mild aeser= aediscon=1 aesevn=. _ERROR_=1 _N_=6Thanks
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.