I have a data of this form:
data one;
input X Y $20.;
infile datalines dlm=',';
datalines;
2.5,7.5 9.5 8.0 8.5
5.0,11.0 12.0 9.0 10.0
7.5,11.0 16.0 12.5 14.0
10.0,16.5 14.5 21.5 19.0
;
run;
And I want to use PROC REG to plot series of graphs. So I used the code below:
proc reg data=one plots=all;
model Y=X / p r clm cli influence;
run;
But I keep encountering this error below:
195 proc reg data=one plots=all; 196 model Y=X / p r clm cli influence; ERROR: Variable Y in list does not match type prescribed for this list. NOTE: The previous statement has been deleted. 197 run;
How do I go about this?
@JUMMY wrote:
I have a data of this form:
data one; input X Y $20.; infile datalines dlm=','; datalines; 2.5,7.5 9.5 8.0 8.5 5.0,11.0 12.0 9.0 10.0 7.5,11.0 16.0 12.5 14.0 10.0,16.5 14.5 21.5 19.0 ; run;
And I want to use PROC REG to plot series of graphs. So I used the code below:
proc reg data=one plots=all; model Y=X / p r clm cli influence; run;
But I keep encountering this error below:
195 proc reg data=one plots=all; 196 model Y=X / p r clm cli influence; ERROR: Variable Y in list does not match type prescribed for this list. NOTE: The previous statement has been deleted. 197 run;How do I go about this?
Proc Reg expects all variables on the model statement to be numeric. Your Y variable is character. That is what type refers to.
It's not even clear to me what the series of graphs is that you want.
So, I'm going to take a guess ...
data one;
input X Y1 y2 y3 y4;
infile datalines;
datalines;
2.5 7.5 9.5 8.0 8.5
5.0 11.0 12.0 9.0 10.0
7.5 11.0 16.0 12.5 14.0
10.0 16.5 14.5 21.5 19.0
;
run;
Do you want a plot of X versus Y1 and then another plot of X versus Y2 and so on? Do you want regression plots (showing the regression line) or scatterplots or both or neither?
Why don't you want to use Y1 Y2 Y3 Y4? This makes everything much simpler.
Do you want four lines and four scatterplots on the same plot; or do you want four different plots?
If your intent is to have 4 values of a single dependent variable then try this:
data one; input X @; do i= 1 to 4; input Y @; output; end; drop i; datalines; 2.5 7.5 9.5 8.0 8.5 5.0 11.0 12.0 9.0 10.0 7.5 11.0 16.0 12.5 14.0 10.0 16.5 14.5 21.5 19.0 ; run; ods graphics on; proc reg data=one plots=all; model Y=X / p r clm cli influence; run; ods graphics off;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.