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