Hi, I have a database with character observations ( y and n) I want to assign them values to calculate the comorbidity index. The code I am using is the following with no result.
data hw2;
set datasets.riskdata;
if diagnosis= 'TYPE1_DM' then diagnosis='2';
if diagnosis='TYPE2_DM' THEN DIAGNOSIS='0';
if diagnosis= 'PXECTMY' then diagnosis='0';
IF los<0 then los=.;
array a{9} diagnosis dialysis cbypass cbv_ds respprob neuropthy mi pvd lipiddis;
do i=1 to 9;
if a{i}= ' ' then a{i}=delete;
end;
run;
data hw2;
set datasets.riskdata;
array a {5} cbypass cbv_ds respprob neuropthy pvd;
do i=1 to 5;
if uppercase(a{i})= 'Y' then a{i}=1;
end;
run;
For your first question, you will need to define a new set of variables. Character variables won't hold numeric values. One possibility:
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.