One way, first creating an actual data set.
data have;
infile datalines dlm=',';
input id :$20. Zip :$5. registered :$1.;
datalines;
660004583468247345,28211,Y
660015613515135135,45286,Y
660351531581351551,72458,N
660044415151535151,106957,Y
1358153,41763,Y
10154543,95847,Y
10071,8547,Y
1000586,65482,Y
10442151,54368,N
8000397,47352,Y
;
data want;
set have;
if id=:'66' then id=substr(id,2);
run;
The =: is a "begins with". Substr says to start at the second character to length of the value and keep that.
Note the data step is the best way to share data. That way we do not have to make guesses as to variable types.
You really did not need to include other variables if they are not involved in the problem.
@Chuckles wrote:
Kinda of stumped with this one so hoping the community can help. In the list of values below.
If the id starts with '66' (not all id's start with 66) the leading 6 should be removed from the value so the value is only 17 characters long. Not all id's are 17 characters long.
Before processing
id,Zip,registered
660004583468247345,28211,Y
660015613515135135,45286,Y
660351531581351551,72458,N
660044415151535151,106957,Y
1358153,41763,Y
10154543,95847,Y
10071,8547,Y
1000586,65482,Y
10442151,54368,N
8000397,47352,Y
What the end result shoudl look like
id,Zip,registered
60004583468247345,28211,Y
60015613515135135,45286,Y
60351531581351551,72458,N
60044415151535151,106957,Y
1358153,41763,Y
10154543,95847,Y
10071,8547,Y
1000586,65482,Y
10442151,54368,N
8000397,47352,Y
Any tips on how to write the code for this?