I have an update statement for a table. Since LPAD does not work in SAS. is there a way to easily pad the zeros?
proc sql;
update <TABLE>
set UNIQUE_KEY = Compress('BI'||lpad('9161',7,'0')||'MTSMBE'||(put(CREATION_DATE_TIME,10.)));
quit;
Are you trying to generate a digit string from a number? If so just use PUT() function and Z format.
put(9161,Z7.)
will generate the string '0009161'.
If your source is already a string (and cannot be converted to an integer using INPUT()) then you will need to work harder.
There are many answers to that question on this forum, although I suspect none of them are using the terminology of "LPAD()" whatever language you got that from.
If the table you are working with is not a "passthru" to an external database (such as Oracle or similar), then use format z10.
Are you trying to generate a digit string from a number? If so just use PUT() function and Z format.
put(9161,Z7.)
will generate the string '0009161'.
If your source is already a string (and cannot be converted to an integer using INPUT()) then you will need to work harder.
There are many answers to that question on this forum, although I suspect none of them are using the terminology of "LPAD()" whatever language you got that from.
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!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.