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!
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: