Hello,
I would like to delete the first variable of the values of the variable CONTEST:
(Package_ID= identification number for each package / CONT_CD=unique code for the contents in the package)
--------------------------------------
Package_ID CONT_CD
1001 XA123
1002 XA225
1003 YA336
---------------------------------------
I would like to simply get ride of the first letter of the Variable CONT_CD so it looks like the following:
--------------------------------------
Package_ID CONT_CD
1001 A123
1002 A225
1003 A336
---------------------------------------
I have tried the following,,
data w.package_want set w.package;
CONT_CD = SUBSTR(2,5) in CONT_CD;
RUN;
but I am getting an error.
Any advice or help would be really helpful.
Thank you.
Hi,
There are a few issues with your code.
CONT_CD = SUBSTR(2,5) in CONT_CD;
is not correct syntax. Is this valid in some other language (just curious)? Better would be:
CONT_CD = SUBSTR(CONT_CD,2,5);
But in case the variable CONT_CD is only 5 positions long, this could give messages about an invalid third argument because you reach beyond the end of the string. A safe approach is simply ommiting the third argument, as that indicates "to the end".
CONT_CD = SUBSTR(CONT_CD,2);
Hope this helps,
- Jan.
Hi,
Please try this.
data want;
set have;
substr(strip(CONT_CD),1,1)='';
run;
Hi,
There are a few issues with your code.
CONT_CD = SUBSTR(2,5) in CONT_CD;
is not correct syntax. Is this valid in some other language (just curious)? Better would be:
CONT_CD = SUBSTR(CONT_CD,2,5);
But in case the variable CONT_CD is only 5 positions long, this could give messages about an invalid third argument because you reach beyond the end of the string. A safe approach is simply ommiting the third argument, as that indicates "to the end".
CONT_CD = SUBSTR(CONT_CD,2);
Hope this helps,
- Jan.
Thank you very much for your help!
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.