BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mgrzyb
Quartz | Level 8

Hello I hope you are all well.

 

I have IDs, such AB124008 in which AB = site of enrollment, 12, represents MD id, and 40008 represents the actual patient id in the study. 

 

I looked through all  of Cody's books, or most, and know that I probably am missing something. 

They  are all character / text variables. 

 

How do  I separate all the IDs into:

1) site of enrollment - want it to be a text var

2) physician code - want to it to be a number

3) actual id - want to be a number

 

 

Thanks!

I have many enrolled patients in the study.  I know there has to be an array to separate them.  

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

is your question complete? Meaning do all your obs follow the same pattern for extraction? If yes,

 

data w;
k='AB124008';
siteofenrollment=substr(k,1,2);
physiciancode=input(substr(k,3,2),8.);
actualid=input(substr(k,5),8.);
run;

View solution in original post

3 REPLIES 3
novinosrin
Tourmaline | Level 20

is your question complete? Meaning do all your obs follow the same pattern for extraction? If yes,

 

data w;
k='AB124008';
siteofenrollment=substr(k,1,2);
physiciancode=input(substr(k,3,2),8.);
actualid=input(substr(k,5),8.);
run;
mgrzyb
Quartz | Level 8

Thank you so much!!!!

ballardw
Super User

@mgrzyb wrote:

Hello I hope you are all well.

 

I have IDs, such AB124008 in which AB = site of enrollment, 12, represents MD id, and 40008 represents the actual patient id in the study. 

 

I looked through all  of Cody's books, or most, and know that I probably am missing something. 

They  are all character / text variables. 

 

How do  I separate all the IDs into:

1) site of enrollment - want it to be a text var

2) physician code - want to it to be a number

3) actual id - want to be a number

 

 

Thanks!

I have many enrolled patients in the study.  I know there has to be an array to separate them.  


What arithmetic are you performing on physician code and actual id? If none, why a number?

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
  • 3 replies
  • 1526 views
  • 0 likes
  • 3 in conversation