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!
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
Hmmmm ... don't much care if you can see it on the output. Can you see it in the input data set MS_Citizens?
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.
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
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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.