BookmarkSubscribeRSS Feed
mariamabotaleb
Calcite | Level 5

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 

2 REPLIES 2
Astounding
PROC Star

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.

mariamabotaleb
Calcite | Level 5

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

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 721 views
  • 0 likes
  • 2 in conversation