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.
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 lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.