Hello,
I have a set of variables (diagnostic codes 1-10) that I need combine them in one new variable (DC_F) and then:
1- Substring the first letter in the 10 variables (eg F111-> F)
2- Count the number of Fs in each variable and sum them in (DC_F)
I have already created an array and searched some codes:
Data want;
set have;
Array DIAGNOSTIC_CODES Diag_code_1-Diag_code_10 ;
Do i= 1 to 10;
if DIAGNOSTIC_CODES[i] in("T***") then T***=1 ;
end;
run;
Thanks
Is each observation supposed to have its own total number of "F"s?
Is each variable supposed to have its own total number of "F"s?
Is TC_F supposed to be a count for the entire data set, or a separate count for each observation?
All of this is easy to do ... we just need to know what you want.
Is each observation supposed to have its own total number of "F"s? Yes
Is each variable supposed to have its own total number of "F"s? Yes
I would like to have the sum of Fs in each observation and then the total number of F
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.