I have a data set that has a character variable ($poc) and would like to replace it with 2 new variables: t (F2.0) and site ($2). Is that possible without the need to output to a raw data file and re-enter it? Thanks.
Have:
POC17DB
POC17BB
POC17MB
POC17ML
POC17LL
POC17DL
POC16DB
POC16BB
POC16MB
POC16ML
POC16LL
Want:
17 DB
17 BB
17 MB
17 ML
17 LL
17 DL
16 DB
16 BB
16 MB
16 ML
16 LL
Will your data always be
Three letters
Two numbers
Two letters
or can you have single digit or three digit numbers and single letter or three letter sites?
Yes the data has a fixed format: 3 letters, 2 numbers, 2 letters
Thanks Peter. I solved it using the substr function:
a = substr(site, 4, 2);
b = substr(site, 6, 2);
Thanks again.
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.