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.
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.