i am using the below condition and want to make it standard. but for some sstudies the variable name "aeacn" is "aacn". is there any way where i can make sure that if it is aacn then also it needs to consider.
data inc;
set adae;
if strip(aeacn)="" and strip(withdraw)="" then aeact_use="";
else if aecontrt="N" and strip(upcase(aeacn)) in ("", "NA", "DOSE NO CHANGED") then aeact_use="0";
else do;
if aecontrt="Y" then aeact_use="1";
if strip(upcase(aeacn)) not in ("", "NOT APPLICABLE", "DOSE NOT CHANGED", "DOSE NO CHANGED") then do;
if aeact_use="" then aeact_use="8";
end;
run;
Sorry. Unlike in SQL in a data step SAS uses different functions for character and numeric values.
You will need to use the coalesceC() function.
Your code seems to be missing an END.
I think your question is related to having inconsistent input data structures?
If so then just add code to make the data consistent and then run the same logic.
So if your code references variable A and your input could have A or B then add something like this:
length A B $30 ;
A=coalesce(A,B);
That way A is always defined and wil have the first non missing value between the two variables.
Thanks tom.
I i use your solution i get the following note
NOTE: Invalid numeric data for that variable
sorry code which i modified
data inc;
set adae;
length aeacn aacn $30 ;
aeacn=coalesce(aeacn,aacn);
if strip(aecontrt)="" and strip(aeacn)="" and strip(withdraw)="" then aeact_use="";
else if aecontrt="N" and strip(upcase(aeacn)) in ("", "NOT APPLICABLE", "DOSE NOT CHANGED", "DOSE NO CHANGED") and withdraw="N" then aeact_use="0";
else do;
if aecontrt="Y" then aeact_use="1";
if strip(upcase(aeacn)) not in ("", "NOT APPLICABLE", "DOSE NOT CHANGED", "DOSE NO CHANGED") then do;
if aeact_use="" then aeact_use="2";
else aeact_use=strip(aeact_use)||",2";
end;
if withdraw="Y" then do;
if aeact_use="" then aeact_use="3";
else aeact_use=strip(aeact_use)||",3";
end;
end;
run;
Sorry. Unlike in SQL in a data step SAS uses different functions for character and numeric values.
You will need to use the coalesceC() function.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.