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!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.