Hello,
In SAS where I have a data table in the work . What line of code do I use to convert a character column to text column with leading zeros. For example, in the column SSN, it has numeric digits but some don't have leading 0s. Like for example, it is has 11 instead of 0011. How do I convert all the values in that column in a character type column with leading zeros to signify the last four of a social security number.
@kmin87 wrote:
I want the last four social security with leading zeros. For example one of the value in the column is 11 in numeric format and I want it to be 0011 in character format in a new column in a new data set
data test; ssn =999560011; lastfour = substr(put(ssn,ssn.),8); run;
You don't need to convert SSNs. Try this:
data test;
ssn = 11;
format ssn ssn.;
put ssn =;
run;
i
I want the last four social security with leading zeros. For example one of the value in the column is 11 in numeric format and I want it to be 0011 in character format in a new column in a new data set
@kmin87 wrote:
I want the last four social security with leading zeros. For example one of the value in the column is 11 in numeric format and I want it to be 0011 in character format in a new column in a new data set
data test; ssn =999560011; lastfour = substr(put(ssn,ssn.),8); run;
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.