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
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!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.