BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Cooksam13
Fluorite | Level 6

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?

 

 

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 Data Work.Vitals1;
74 Set Vitals10
75 vitals11
76 vitals12
77 Vitals13
78 vitals14;
79 Keep ApptDate
80 SSN
81 Measure
82 Value;
83 Rename ApptDate = VisitDt;
84 Format SSN $SSN.;
_____
484
NOTE 484-185: Format $SSN was not found or could not be loaded.
 
85
86
87 Run;
 
 
1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

@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_2010
128 HypImpt.utah_vitals_2011
129 HypImpt.Utah_vitals_2012
130 HYpImpt.Utah_Vitals_2013
131 hypimpt.Utah_vitals_2014;
132 Keep ApptDate
133 SSN
134 Measure
135 Value;
136 Rename ApptDate = VisitDt;
137 Format SSN $SSN.;
_____
484
NOTE 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.

--
Paige Miller

View solution in original post

10 REPLIES 10
PaigeMiller
Diamond | Level 26

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).

--
Paige Miller
Cooksam13
Fluorite | Level 6

SSN is a character value with 9 characters 

 

examples are 

528536558

529105349

528887912

Cooksam13
Fluorite | Level 6
SSN is a character value with 9 characters



examples are

528536558

529105349

528887912
PaigeMiller
Diamond | Level 26

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 */
--
Paige Miller
Cooksam13
Fluorite | Level 6
thanks this works but i need to keep it a character. how would i do that?
PaigeMiller
Diamond | Level 26

@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

--
Paige Miller
ballardw
Super User

@Cooksam13 wrote:
SSN is a character value with 9 characters



examples are

528536558

529105349

528887912

Which means the numeric format SSN cannot be used.

Cooksam13
Fluorite | Level 6

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 

126 Data Work.Vitals;
127 Set Vitals
128 vitals11
129 vitals12
130 Vitals13
131 vitals14;
132 Keep ApptDate
133 SSN
134 Measure
135 Value;
136 Rename ApptDate = VisitDt;
137 Format SSN $SSN.;
_____
484
NOTE 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 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?

PaigeMiller
Diamond | Level 26

@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_2010
128 HypImpt.utah_vitals_2011
129 HypImpt.Utah_vitals_2012
130 HYpImpt.Utah_Vitals_2013
131 hypimpt.Utah_vitals_2014;
132 Keep ApptDate
133 SSN
134 Measure
135 Value;
136 Rename ApptDate = VisitDt;
137 Format SSN $SSN.;
_____
484
NOTE 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.

--
Paige Miller

sas-innovate-wordmark-2025-midnight.png

Register Today!

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.


Register now!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 10 replies
  • 1861 views
  • 2 likes
  • 4 in conversation