I have numeric values like:
12
126
145698
I want to convert them into 6 digit character with trailing zeros. The above numbers should appear as:
000012
000126
145698
data new; set old;
zip5_char15 = put(gvkey, $6.);
length zipx $ 6;
zipx = left(zip5_char15);
gvkey_char = substr(("00000"||zipx),length(zipx),6);
drop zip5_char15 zipx;
run;
data new; set old;
zip5_char15 = put(gvkey, $6.);
length zipx $ 6;
zipx = left(zip5_char15);
gvkey_char = substr(("00000"||zipx),length(zipx),6);
drop zip5_char15 zipx;
run;
Thanks. This was very quick. I appreciate it.
data have; input x; want=put(x,z6.); cards; 12 126 145698 ;
Thanks. I just corrected it.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.