Help using Base SAS procedures

Proc means error: does not match type prescribed for this list.

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 77
Accepted Solution

Proc means error: does not match type prescribed for this list.

I'm trying to get some descriptive stats from an age variable in my dataset. I am using this simple code:

 

proc means data=janfeb.sampleage;
var ageyr;
run;

However, I'm getting this error:

 

 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 61         
 62         proc means data=janfeb.sampleage;
 63         var ageyr;
 ERROR: Variable ageyr in list does not match type prescribed for this list.
 64         run;
 
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE MEANS used (Total process time):
       real time           0.02 seconds
       cpu time            0.02 seconds
       
 65         
 66         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 79         

Here is a sample dataset I'm using:

data JANFEB.SAMPLEAGE;
  infile datalines dsd truncover;
  input ageyr:$3.;
datalines4;
75
81
72
75
65
64
80
67
66
66
62
70
72
60
60
67
89
79
75
77
60
62
65
85
64
64
64
68
68
61
79
78
82
61
61
80
77
74
70
85
77
73
72
65
64
60
79
62
73
76
74
72
68
60
67
61
83
61
77
60
71
68
65
86
69
75
61
75
64
79
64
71
69
63
83
83
72
65
60
75
60
79
76
73
68
78
61
78
61
74
61
80
74
62
81
79
64
79
71
69
;;;;

Not sure what is going on, appreciate the help. Thank you.


Accepted Solutions
Solution
‎04-05-2017 06:25 AM
Super User
Super User
Posts: 7,413

Re: Proc means error: does not match type prescribed for this list.

If your reading it in, then:

data JANFEB.SAMPLEAGE;
  infile datalines dsd truncover;
  input ageyr;
datalines4;
75
81
...
;

If it already exists, use input() function:

data want;
  set have;
  num_var=input(ageyr,best.);
run;

View solution in original post


All Replies
Super User
Super User
Posts: 7,413

Re: Proc means error: does not match type prescribed for this list.

Simple, proc means expects a numeric variable.  In your test data you are creating a character variable:

  input ageyr:$3.;
^

 

Frequent Contributor
Posts: 77

Re: Proc means error: does not match type prescribed for this list.

On another dataset, how do i convert this variable into numeric only?

##- Please type your reply above this line. Simple formatting, no
attachments. -##
Solution
‎04-05-2017 06:25 AM
Super User
Super User
Posts: 7,413

Re: Proc means error: does not match type prescribed for this list.

If your reading it in, then:

data JANFEB.SAMPLEAGE;
  infile datalines dsd truncover;
  input ageyr;
datalines4;
75
81
...
;

If it already exists, use input() function:

data want;
  set have;
  num_var=input(ageyr,best.);
run;
Frequent Contributor
Posts: 77

Re: Proc means error: does not match type prescribed for this list.

Is there any way to use the input function on its own variable without creating a new one? Thanks

Super User
Super User
Posts: 7,413

Re: Proc means error: does not match type prescribed for this list.

No, you can't put numeric data into a character variable.  So if you tried:

char_var=input("01",best.);

The return would be:

char_var=01;

And as char_var is character, it would implicitly change 01 to be "01", back to your issue again.  Hence why datatypes are important, if you have numeric data keep it as numeric.

☑ This topic is solved.

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

Discussion stats
  • 5 replies
  • 172 views
  • 1 like
  • 2 in conversation