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

Hello there,

SAS keeps saying that the variable type is not on file....What does this mean? WHen I did a one way frequency table without the where statement it ran...But when I made this edit, it didn't. 

 

Code:
proc freq data=WORK.SYPHILIS;
	tables genderB genderC sex_o RACE age / plots=(freqplot cumfreqplot);
	where Type in ("genderB", "genderC", "sex_o", "race") and 18<=age<=50;
run;

Log: 

1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 SYMBOLGEN:  Macro variable _SASWSTEMP_ resolves to /home/u49152646/.sasstudio/.images/db1b9e49-6774-45a2-9899-069be7ad3673
 SYMBOLGEN:  Some characters in the above value which were subject to macro quoting have been unquoted for printing.
 SYMBOLGEN:  Macro variable GRAPHINIT resolves to GOPTIONS RESET=ALL GSFNAME=_GSFNAME;
 72         
 73         /*
 74          *
 75          * Task code generated by SAS Studio 3.8
 76          *
 77          * Generated on '8/10/20, 8:32 AM'
 78          * Generated by 'u49152646'
 79          * Generated on server 'ODAWS03-USW2.ODA.SAS.COM'
 80          * Generated on SAS platform 'Linux LIN X64 3.10.0-1062.9.1.el7.x86_64'
 81          * Generated on SAS version '9.04.01M6P11072018'
 82          * Generated on browser 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
 82       ! Chrome/84.0.4147.105 Safari/537.36'
 83          * Generated on web client
 83       ! 'https://odamid-usw2.oda.sas.com/SASStudio/main?locale=en_US&zone=GMT-07%253A00&ticket=ST-27624-sinmcsizLgE19kH9QBkl-cas'
 84          *
 85          */
 86         
 87         proc freq data=WORK.SYPHILIS;
 88         tables genderB genderC sex_o RACE age / plots=(freqplot cumfreqplot);
 89         where Type in ("genderB", "genderC", "sex_o", "race") and 18<=age<=50;
 ERROR: Variable Type is not on file WORK.SYPHILIS.
1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
Run a PROC CONTENTS on your data set and check the name AND label of your variables.

View solution in original post

9 REPLIES 9
Reeza
Super User
Run a PROC CONTENTS on your data set and check the name AND label of your variables.
Kimberly_2020
Calcite | Level 5

And I already imported the CSV file into SAS

Kimberly_2020
Calcite | Level 5

That worked but it gave me a frequency table for all ages and not age 18-50 like before. My instructions were to create a frequency table of current gender and sexual orientation for patients between the age of 18 - 50 years.

 

proc freq data=WORK.SYPHILIS;
	proc contents data=work.syphilis;
	tables genderB genderC sex_o RACE age / plots=(freqplot cumfreqplot);
	where Type in ("genderB", "genderC", "sex_o", "RACE") and 18<=age<=50;
run;

 

Reeza
Super User
It seems like you're confusing variable values and variable names.

Is your variable called type with values of genderB, genderC or do you have variables called genderB, genderC?

I guarantee that code is not correct or at least what you want or expect.
Kimberly_2020
Calcite | Level 5

variables called genderB and genderC

Reeza
Super User
I'm guessing the error means SAS doesn't think you have a variable called TYPE in your syphilis data base. You can check this in your IMPORT code or via PROC CONTENTS. You'll want to check the label versus name as well, this is a common mistake to use the labels instead of names.
Reeza
Super User
proc freq data=WORK.SYPHILIS;
where18<=age<=50;
tables genderB genderC sex_o RACE age / plots=(freqplot cumfreqplot);
run;

This is likely what you want. 

 

Your TYPE portion doesn't make sense since those are variable names. Not sure what you were expecting to happen within that portion of code but it doesn't do what you think it does 🙂

Kimberly_2020
Calcite | Level 5

It worked! Thank you! 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 9 replies
  • 1538 views
  • 0 likes
  • 2 in conversation