I am working on a snippet where I am formatting SSN. In the past, the Z format worked, but it has not worked lately. I tried using picture (for example, picture ssfmt other = '999999999';), but that hasn't worked as well. I am getting an error that states that the format was not found or could not be loaded.
proc format;
picture ssfmt low-high = '999999999';
run;
ID starts of with a character of 20 length. Then I do the following:
length newid $9.;
newid =idnumber;
newssn = input(newid, ssfmt.);
Any pointers?
Thanks,
Why no use the SSN format.
Thanks for the reply, but I am getting the error that the format could not be found or loaded.
Is it possible that your variable is character, but in previous applications it was numeric?
It is a character variable what I am using.
If it is character then perhaps you should read it (input function) into a numeric variable then apply SSN format to the new variable.
As you noticed, SAS complains when you try to apply a numeric format (such as ssn. or z9.) to a character variable. Since your variable is defined as 20 characters long, you can replace it with the proper value using the tools that data_null_ suggested:
idnumber = put(input(left(idnumber),9.), ssn.);
If you want to keep IDNUMBER as is, you could always assign this value to a new variable instead.
Good luck.
Thank you! That worked and I did a compress to get rid of the hyphens.
Ah, if you don't want the hyphens it's just slightly different:
idnumber = put(input(left(idnumber),9.), z9.);
Thank you! I'll never understand when Z works and when it doesn't.
It works when the data is NUMERIC. Does not work for character data.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.