data have;
Input alpha : $5.;
cards;
00100
1019
099
185
1010
0803
12398
;
run;
data want;
set have;
substr(alpha,length(alpha)+1) = '00000';
length test1 $6;
test1 = substr(alpha,1,3) !! '.' !! substr(alpha,4);
run;
You could read the data as below:
@sowmya not all the data will need a trailing zeros, as you can see on what the result should look like.
Thanks!
data have;
Input alpha : $5.;
cards;
00100
1019
099
185
1010
0803
12398
;
run;
data want;
set have;
substr(alpha,length(alpha)+1) = '00000';
length test1 $6;
test1 = substr(alpha,1,3) !! '.' !! substr(alpha,4);
run;
This is perfect!Thank you very much!
Just replace the blanks in alpha with zeros an your code will produce the required resulsts.
data want;
set have;
alpha = translate(alpha, '0', ' ');
test1=substr(alpha,1,3)||'.'|| substr(alpha,4,2); /* add a period to fields*/
run;
Another great solution. Thank youvery much!
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.