Hi i am trying to format my SSN numbers to have the dashes in it
I have used the SSN11. SSN. $SSN. $SSN11. and i get an error each time. can some one help?
@Cooksam13 wrote:
Hi, i just asked this question but i thought i should clarify more what I need to happen
I am combing data sets vertically and one of my data sets will not change the SSN format it is in. I need to have them be in the 11 character format. The SSN is currently in Character format with 9 characters.
I currently have this
*Creating data for Utah *;126 Data Work.Vitals_UT1;127 Set Hypimpt.utah_Vitals_2010128 HypImpt.utah_vitals_2011129 HypImpt.Utah_vitals_2012130 HYpImpt.Utah_Vitals_2013131 hypimpt.Utah_vitals_2014;132 Keep ApptDate133 SSN134 Measure135 Value;136 Rename ApptDate = VisitDt;137 Format SSN $SSN.;_____484NOTE 484-185: Format $SSN was not found or could not be loaded.
however in my original code '$' is not included in it for SSN.
The examples of data i have are
008276992 036788134
044905089
Work.Vitals_UT1 will be added to several other data sets and that is where the problem is coming from. "SSN is categorized as characters and numbers in other data sets"
But every data set besides Work.Vitals_Ut1 is in the correct format of SSN11. so i know that Work.Vitals_UT is the culprit. can someone please help?
So, if I am understanding this properly, you have SSNs character variables that are 11 characters long in some data sets, and SSNs that are character variables that are 9 characters long in other data sets, and you are trying to merge the data sets by SSN.
Is that a correct statement?
So, in the data sets with SSNs that are character variables that are 9 characters long, this ought to work:
data new;
length ssn $ 11;
set old;
SSN1 = input(SSN,9.); /* Creates a numeric variable SSN1 */
format ssn1 ssn.; /* Apply format to SSN1 */
ssn=vvalue(ssn1); /* Convert properly formatted SSN1 to character variable 11 characters long */
run;
and now SSN is a character variable 11 characters long.
SSN is a numeric format, so the $ is not needed (in fact, it is wrong to use it there), and applies to only numeric variables. Is SSN a numeric variable?
What is a typical value of SSN in your data set? Please show us a few examples (or a screen capture of SSN in the data set).
SSN is a character value with 9 characters
examples are
528536558
529105349
528887912
It can't be character, it has to be numeric.
Try this
SSN1 = input(SSN,9.); /* Creates a numeric variable SSN1 */
format ssn1 ssn.; /* Apply format to SSN1 */
@Cooksam13 wrote:
thanks this works but i need to keep it a character. how would i do that?
SSN is character
SSN1 is numeric
What isn't working if you use properly formatted SSN1 instead of SSN
@Cooksam13 wrote:
SSN is a character value with 9 characters
examples are
528536558
529105349
528887912
Which means the numeric format SSN cannot be used.
Hi, i just asked this question but i thought i should clarify more what I need to happen
I am combing data sets vertically and one of my data sets will not change the SSN format it is in. I need to have them be in the 11 character format. The SSN is currently in Character format with 9 characters.
I currently have this
however in my original code '$' is not included in it for SSN.
The examples of data i have are
008276992 |
036788134
044905089
Work.Vitals will be added to several other data sets and that is where the problem is coming from. "SSN is categorized as characters and numbers in other data sets"
But every data set besides Work.Vitals is in the correct format of SSN11. so i know that Work.Vitals is the culprit. can someone please help?
If you need to clarify something, please do it in the original thread. That's why I moved your post here.
@Cooksam13 wrote:
Hi, i just asked this question but i thought i should clarify more what I need to happen
I am combing data sets vertically and one of my data sets will not change the SSN format it is in. I need to have them be in the 11 character format. The SSN is currently in Character format with 9 characters.
I currently have this
*Creating data for Utah *;126 Data Work.Vitals_UT1;127 Set Hypimpt.utah_Vitals_2010128 HypImpt.utah_vitals_2011129 HypImpt.Utah_vitals_2012130 HYpImpt.Utah_Vitals_2013131 hypimpt.Utah_vitals_2014;132 Keep ApptDate133 SSN134 Measure135 Value;136 Rename ApptDate = VisitDt;137 Format SSN $SSN.;_____484NOTE 484-185: Format $SSN was not found or could not be loaded.
however in my original code '$' is not included in it for SSN.
The examples of data i have are
008276992 036788134
044905089
Work.Vitals_UT1 will be added to several other data sets and that is where the problem is coming from. "SSN is categorized as characters and numbers in other data sets"
But every data set besides Work.Vitals_Ut1 is in the correct format of SSN11. so i know that Work.Vitals_UT is the culprit. can someone please help?
So, if I am understanding this properly, you have SSNs character variables that are 11 characters long in some data sets, and SSNs that are character variables that are 9 characters long in other data sets, and you are trying to merge the data sets by SSN.
Is that a correct statement?
So, in the data sets with SSNs that are character variables that are 9 characters long, this ought to work:
data new;
length ssn $ 11;
set old;
SSN1 = input(SSN,9.); /* Creates a numeric variable SSN1 */
format ssn1 ssn.; /* Apply format to SSN1 */
ssn=vvalue(ssn1); /* Convert properly formatted SSN1 to character variable 11 characters long */
run;
and now SSN is a character variable 11 characters long.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.