BookmarkSubscribeRSS Feed
JUMMY
Obsidian | Level 7

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?

5 REPLIES 5
ballardw
Super User

@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.

PaigeMiller
Diamond | Level 26

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?

--
Paige Miller
JUMMY
Obsidian | Level 7
@PaigeMiller, I want regression plots showing the regression line as well as the scatterplots. Is there a way to plot other without using Y1-Y4?
PaigeMiller
Diamond | Level 26

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?

--
Paige Miller
ballardw
Super User

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;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1641 views
  • 0 likes
  • 3 in conversation