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:
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Get started using SAS Studio to write, run and debug your SAS programs.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.