How to change "001234" to "1234" in all rows of a column?
In one of my columns in the dataset I have customerIDs with "00" added before. I want to delete it at all rows.
Is this possible?
Kind regards,
Sandra
Try this
data have;
CustomerID = "001234";
run;
data want;
set have;
id = substr(CustomerID, verify(CustomerID,'0'));
run;
data want;
set have;
y=substr(x,1,2)
If y="00" then x1=substr(x,3,4);
else x1=x;
run;
@Sandra94 wrote:In one of my columns in the dataset I have customerIDs with "00" added before. I want to delete it at all rows.
Is this possible?
Kind regards,
Sandra
data want;
set have;
if substr(customerIDs,1,2) ="00" then delete;
run;
I understand that the variable CustomerID is char type and its length is 6.
Alternative ways to those already posted:
1) customeID = put(input(customeID ,6.),6.);
2) Change the type of the variable to numeric:
data want;
set have(rename=(customeID =CID));
customeID = input(CID,6.);
format customeID 6.;
run;
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 save with the early bird rate—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.