If it is already stored as character, do this:
zipcode = put(input(zipcode,best.),z6.);
else, you need to convert to character:
zipcode_char = put(zipcode,z6.);
or you simply assign it the format for display:
format zipcode z6.;
Depends. Try it and see if it meets your requirements.
Converting to number and then using a format provides for the simplest code. But you might to have to solve other issues (blanks within zipcodes etc) first for this to work.
In this like in most other cases, testing beats speculating
(German: "Probieren geht über studieren", English: "The proof of the pudding is in the eating")
Whilst I agree with the above, if number convert is easiest, if the data contains non numerics that isn't going to work, so here is a text version:
data want; input zip $; if lengthn(zip) < 6 then zip=cats(repeat("0",5-lengthn(zip)),zip); datalines; 12345 123456 12AE4 1 ; run;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.