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

Hello! 

 

My variable SSN (social security number) has the following attributes:

Obs 1: 485-40-2594

Length: 12

Type: Char

Format: $12.

Informat: $12.

 

I am trying to create (or modify the current variable) that has the same name and values (SSN) but with a length of $11 and no formats or informats. When using LENGTH statements I end up with a warning in my log about truncating the variable. I do want the variable to sustain the same format of XXX-XX-XXXX.

 

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

So it sounds like you have this data:

data have;
  attrib SSN length=$12 format=$12. informat=$12. ;
  input ssn;
cards;
485-40-2594
;

And you did something like this:

data want ;
  length SSN $11;
  set have;
  format ssn;
  informat ssn;
run;

To avoid the warning you can just make a new variable instead.  That will also mean you don't need to do anything to remove format or informat (as long you you never attach any format or informat to the new variable).

data want ;
  set have;
  length new $11;
  new=ssn;
  drop ssn;
  rename new=SSN;
run;

 

View solution in original post

2 REPLIES 2
andreas_lds
Jade | Level 19

Something like:

data want;
  set have(rename=(ssn=old_ssn));
  length ssn $ 11;
  drop old_ssn;
  ssn = substr(old_ssn, 1, 11);
run;
Tom
Super User Tom
Super User

So it sounds like you have this data:

data have;
  attrib SSN length=$12 format=$12. informat=$12. ;
  input ssn;
cards;
485-40-2594
;

And you did something like this:

data want ;
  length SSN $11;
  set have;
  format ssn;
  informat ssn;
run;

To avoid the warning you can just make a new variable instead.  That will also mean you don't need to do anything to remove format or informat (as long you you never attach any format or informat to the new variable).

data want ;
  set have;
  length new $11;
  new=ssn;
  drop ssn;
  rename new=SSN;
run;

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 2 replies
  • 1173 views
  • 1 like
  • 3 in conversation