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

I am attempting to create a tabulation from a data set for a project, but the code I have produces an error in my log. I provided a snapshot of my code below. When I run my code, I get this error in my log: "WARNING: The variable SSN in the DROP, KEEP, or RENAME list has never been referenced" and "Variable SSN not found". Everything else is read in and I can see it in the output data, but I am not sure why SAS isn't able to read my SSN variable. Let me know if you need more information on my code, thank you in advance!

 

DATA WORK.Contact_MS;
      RETAIN SSN Inits CityState StateCd ZipCd;
      SET HypImpt.MS_Citizens
              ( RENAME = ( ZipCd = ZipCdNum ) );
                      ZipCd = PUT(ZipCdNum, 5.);
    DROP ZipCdNum;
 
    LABEL SSN = 'Social Security Number'
                 Inits = 'Subject Initials'
                 City = 'City'
          StateCd = 'State Code'
             ZipCd = 'Zip Code';
    LENGTH      Inits $ 3
                  StateCd $ 2;
 
       City = SCAN(CityState, 1, ',');
       City = PROPCASE(City);
StateCd = CAT(SUBSTR(State, 1, 1), SUBSTR(State, 4,1));
      Inits = CATS(SUBSTR(FirstInit, 1, 1), SUBSTR(MiddleInit, 1, 1), SUBSTR (LastInit, 1, 1));
 
      KEEP  SSN Inits City StateCd ZipCd;
 
RUN;
 
 
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Does your HypImpt.MS_Citizens set actually have a variable name SSN? That is the message I would expect to see if it does not actually have the variable named. The example below creates a data that does not have a variable that is then referenced the way you have:

30   data example;
31      x=3;
32   run;

NOTE: The data set WORK.EXAMPLE has 1 observations and 1
      variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


33
34   data junk;
35     retain ssn;
36     set example;
37    keep x ssn;
38   run;

NOTE: Variable ssn is uninitialized.
WARNING: The variable ssn in the DROP, KEEP, or RENAME list has
         never been referenced.
NOTE: There were 1 observations read from the data set
      WORK.EXAMPLE.
NOTE: The data set WORK.JUNK has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds

View solution in original post

4 REPLIES 4
Astounding
PROC Star

Hmmmm ... don't much care if you can see it on the output.  Can you see it in the input data set MS_Citizens?

Kurt_Bremser
Super User

I am very sure that the code you posted does not result in the ERROR you described.

Scan your whole log for the first ERROR or WARNING, and then post the log from that step by copy/pasting it into a code box opened with the </> button.

ballardw
Super User

Does your HypImpt.MS_Citizens set actually have a variable name SSN? That is the message I would expect to see if it does not actually have the variable named. The example below creates a data that does not have a variable that is then referenced the way you have:

30   data example;
31      x=3;
32   run;

NOTE: The data set WORK.EXAMPLE has 1 observations and 1
      variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


33
34   data junk;
35     retain ssn;
36     set example;
37    keep x ssn;
38   run;

NOTE: Variable ssn is uninitialized.
WARNING: The variable ssn in the DROP, KEEP, or RENAME list has
         never been referenced.
NOTE: There were 1 observations read from the data set
      WORK.EXAMPLE.
NOTE: The data set WORK.JUNK has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds

rodrima4
Calcite | Level 5

I just checked and that ended up being my issue! The variable wasn't under SSN, it was under a different name so I had to go back and rename my variable as SSN. Thank you!

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
  • 4 replies
  • 1111 views
  • 0 likes
  • 4 in conversation