DATA Step, Macro, Functions and more

SAS ERROR: Variable XXX in list does not match type prescribed for this

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 17
Accepted Solution

SAS ERROR: Variable XXX in list does not match type prescribed for this

Hello,

I'm a student learning base SAS with university edition.

 

My instruction for this step is as follows:

4)  Create a Means Table using Proc Means:

  1.          i)  Include in your table only the variables:  Gender and Age
  2.         ii)  Format the Age variable using your age format in step 2.

         iii)  Please interpret your Proc Means output by answering the following questions  

                    4a)  What is the mean age of a female in the "Under 30" age group?

                    4b)  What is the mean age of a male in the "Over 50" age group?

 

The problem I'm having is that I keep getting this error on my last data step {proc mean}:

ERROR: Variable gender in list does not match type prescribed for this list.

My code and log are as follows:

libname RV '/folders/myfolders/Week 7'; /*Recall previous permanent dataset*/

data rv.RV_Market_Analysis; /*new dataset*/
	set rv.rv_marketdo; /*previous dataset*/
run;

proc print data=rv.rv_market_analysis;
run;

Proc format;
	value bracket 0-29='Under 30'
			30-50='30-50'
			50-100='Over 50';
run;

Data rv.RV_Market_Analysis;
	set rv.RV_Market_Analysis;
	label Age_Bracket = 'Age Bracket';
	Age_Bracket = PUT(Age, bracket.);
run;

proc print data=rv.rv_market_analysis label;
run;

proc freq data=rv.rv_market_analysis;
	format age bracket.;
	tables age*gender;
run;

proc means data=rv.rv_market_analysis;
	format age bracket.;
	class age gender;
	var age gender;
run; 
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
61
62 proc means data=rv.rv_market_analysis;
63 format age bracket.;
64 class age gender/missing;
65 var age gender;
ERROR: Variable gender in list does not match type prescribed for this list.
66 run;
 
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE MEANS used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
 
67
68 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
81
 
Thanks, in advance for your help!

Accepted Solutions
Solution
‎04-02-2017 04:39 PM
PROC Star
Posts: 7,492

Re: SAS ERROR: Variable XXX in list does not match type prescribed for this

You didn't show us your data, but it looks like you are trying to get the average of values like "M" and "F".

 

I think what you want for that last step is:

 

proc means data=rv.rv_market_analysis;
	class gender age_bracket;
	var age;
run; 

Art, CEO, AnalystFinder.com

View solution in original post


All Replies
Solution
‎04-02-2017 04:39 PM
PROC Star
Posts: 7,492

Re: SAS ERROR: Variable XXX in list does not match type prescribed for this

You didn't show us your data, but it looks like you are trying to get the average of values like "M" and "F".

 

I think what you want for that last step is:

 

proc means data=rv.rv_market_analysis;
	class gender age_bracket;
	var age;
run; 

Art, CEO, AnalystFinder.com

Occasional Contributor
Posts: 17

Re: SAS ERROR: Variable XXX in list does not match type prescribed for this

Thank you for your help!

Super User
Posts: 19,877

Re: SAS ERROR: Variable XXX in list does not match type prescribed for this


bldudley wrote:

Hello,

I'm a student learning base SAS with university edition.

 

My instruction for this step is as follows:

4)  Create a Means Table using Proc Means:

  1.          i)  Include in your table only the variables:  Gender and Age
  2.         ii)  Format the Age variable using your age format in step 2.

         iii)  Please interpret your Proc Means output by answering the following questions  

                    4a)  What is the mean age of a female in the "Under 30" age group?

                    4b)  What is the mean age of a male in the "Over 50" age group?

 

The problem I'm having is that I keep getting this error on my last data step {proc mean}:

ERROR: Variable gender in list does not match type prescribed for this list.

My code and log are as follows:

libname RV '/folders/myfolders/Week 7'; /*Recall previous permanent dataset*/

data rv.RV_Market_Analysis; /*new dataset*/
	set rv.rv_marketdo; /*previous dataset*/
run;

proc print data=rv.rv_market_analysis;
run;

Proc format;
	value bracket 0-29='Under 30'
			30-50='30-50'
			50-100='Over 50';
run;

Data rv.RV_Market_Analysis;
	set rv.RV_Market_Analysis;
	label Age_Bracket = 'Age Bracket';
	Age_Bracket = PUT(Age, bracket.);
run;

proc print data=rv.rv_market_analysis label;
run;

proc freq data=rv.rv_market_analysis;
	format age bracket.;
	tables age*gender;
run;

proc means data=rv.rv_market_analysis;
	format age bracket.;
	class age gender;
	var age gender;
run; 
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
61
62 proc means data=rv.rv_market_analysis;
63 format age bracket.;
64 class age gender/missing;
65 var age gender;
ERROR: Variable gender in list does not match type prescribed for this list.
66 run;
 
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE MEANS used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
 
67
68 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
81
 
Thanks, in advance for your help!

 

Super User
Posts: 19,877

Re: SAS ERROR: Variable XXX in list does not match type prescribed for this

See the comments in the code below.


libname RV '/folders/myfolders/Week 7'; /*Recall previous permanent dataset*/

*This step is useless, you're creating a new dataset that's identical to the old one; data rv.RV_Market_Analysis; /*new dataset*/ set rv.rv_marketdo; /*previous dataset*/ run;
*This doesn't add anything to your project or answer so you don't need this step. Open the dataset instead of printing it; proc print data=rv.rv_market_analysis; run; Proc format; value bracket 0-29='Under 30' 30-50='30-50' 50-100='Over 50'; run;
/*This is bad coding style the SET and DATA statement should have different names.
When you use this type of coding it becomes harder to determine where an error occurred
or when the mistake is. It also means you have to re-run your whole code every time rather than just the latest steps.

Change the SET statement to be the data set from the first data step
*/
Data rv.RV_Market_Analysis; set rv.RV_Market_Analysis; label Age_Bracket = 'Age Bracket'; Age_Bracket = PUT(Age, bracket.); run;
*If you're going to use PRINT at least limit it, so you don't get the full listing
ADD (obs=20) after the data set name;
proc print data=rv.rv_market_analysis label; run; proc freq data=rv.rv_market_analysis; format age bracket.; tables age*gender; run;
/*It's rarely likely to have the CLASS and VAR statements have the same variables.
CLASS is for the variables that you want the analysis grouped by.
VAR is for the variables you want to have statistics, ie mean of variable in VAR.
*/ proc means data=rv.rv_market_analysis; format age bracket.; class age gender; var age gender; run;
 
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 1161 views
  • 0 likes
  • 3 in conversation