Hi community,
I have the below sample data
data have;
input grade bmi;
cards;
0 25.58
2 26.24
3 38.4
1 22.8
2 32.31
0 .
1 55.20
;
run;
proc sgplot data=have;
reg x=grade y=bmi / clm nomarkers;
run;
OR
proc sgplot data=have;
reg x=grade y=bmi / group =grade clm nomarkers;
run;
While run my code, it printed an Output as above image.
But i want my output as below mentioned image.
I tried with different options but it results partial output.
Please help me to get the above output.
Thanks in advance
I run this code:
data have; input grade bmi; cards; 0 25.58 2 26.24 3 38.4 1 22.8 2 32.31 0 . 1 55.20 ; run; proc sgplot data=have; reg x=grade y=bmi / group =grade clm nomarkers; run;
And I get an error:
NOTE: There are insufficient usable observations for REGRESSION fitting for group '0'. ERROR: No REGRESSION fit done for group '1' as the regressor is constant. ERROR: No REGRESSION fit done for group '2' as the regressor is constant. NOTE: There are insufficient usable observations for REGRESSION fitting for group '3'.
Hence not enough data for an actual output, however the graph itself does show grouping is working correctly, with the groups shown?
Sorry for the inconvenience, @RW9
Actually its a sample data. I just use this sample to showcase my issue to get some idea/sample code.
If you required a perfect data, please have a look on the attach (orginal dataset) here.
And its all yours.
Thanks in advance!
I have moved you to the stats procedures section. As stated above the graph produces correctly with the groupings. I cannot however get the reg to and am not a statistician to be able to tell you from your data what is not working.
That's fine.
Thank you for your valuable time to spend it on my issue.
Maybe I am misunderstanding, but your PROC SGPLOT code should give you the output that I think you want. Try the following example, which we can all run.
proc sgplot data=sashelp.cars;
reg x=weight y=mpg_city / group=Origin clm nomarkers;
run;
Do you see the output you want?
Thank you for ur suggestion @Rick_SAS
The weight key word was not respond (Is it a keyword / variable ?)
It results :
proc sgplot data=reg2;
reg x=weight y=fvbmi / group=fvGrade clm nomarkers;
run;
proc sgplot data=reg2;
reg x=weight y=fvbmi / group=fvGrade clm nomarkers;
ERROR: Variable WEIGHT not found.
266 run;
NOTE: The SAS System stopped processing this step because of errors.
For the Yaxis = fvbmi
for the Group = fvGrade
Xaxis = ? - I don't know how to correlate it.
I was asking you to run the code I provided exactly as it is. The data set Sashelp.Cars is included with SAS. It contains the three variables that I reference:
Origin : the grouping variable with values 'Asia', 'Europe', and 'USA'
Weight: The X or explanatory variable (the weight of vehicles, in pounds)
MPG_City : The Y or response variable (the fuel efficiency, in miles per gallon)
After you verify that you run my code without error, we can discuss how to adapt it to your data.
Sorry I misunderstood. (I thought it was a keyword because of the blue font)
Yes this is exactly what I'm looking for.
I want this method to adapt with my data,
My diagram should have to represent with BMI and Grade
In my data I have ID, Bmi, Grade and some other on... in your method 3 variables are used.
There were I stucked.
What model are you trying to visualize? You want the Y variable to be the response (bmi), the X variable to be a continuous covariate in the model, and the GROUP= variable to be a classification effect (Grade?).
You've only posted 2 variables, so I don't know what to suggest. You say you have "ID... and some other ones", so maybe post the first 100-200 observations of your complete data.
Dear @Rick_SAS
The below excel file have the complete dataset.
I just want to visualize, How the each grade has been varies in BMI (fvBmi) value.
> I just want to visualize, How the each grade has been varies in BMI (fvBmi) value.
GRADE seems to be a discrete variable, so I'd use a box plot to visualize the distribution of fvBMI for each grade:
proc sgplot data=Have;
vbox fvbmi / category=fvGrade;
run;
I have to say that a plot, or a regression done in a similar way to
Proc sgplot data=have; reg x=grade y=bmi / group =grade clm nomarkers; run;
Makes absolutely no sense. You are asking for a single plot for each X value. That means all of the points in a regression have the exact same grade.
Run this code and examine what the scatter points look like:
proc sgplot data=sashelp.class; scatter x=age y=height/group=age; run;
There are 6 groups of ages with a vertical plot of the height at each age. The "slope" of the regression line is infinite (vertical). Which is why running a similar regression instead of scatter in the above plot yields a bunch of statements for each group of
ERROR: No REGRESSION fit done for group '11' as the regressor is constant.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.