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!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.