BookmarkSubscribeRSS Feed
Sathish_jammy
Lapis Lazuli | Level 10

Hi Experts, 

May I know how to create a trend line for the given dataset.

It should be categorized by Regression column following by Hba values

data samp;
input Reg Base_Hba FolHba;
cards;
1 7.8 6.7
2 10.3 7
1 7.9 8.4
1 9.9 9.5
2 10.7 7.8
1 9.5 8
1 11.2 9.6
2 10.3 9.1
1 5.6 5.7
1 5.6 7
1 9	8.8
2 11 8.8
2 15.2 7.8
2 9.1 6.3
run;
/*I have tried the below code but flopped*/
proc gplot data=gp2; plot Reg*Base_Hba Reg*FolHba/overlay; run;

Thanks in advance;

 

3 REPLIES 3
PaigeMiller
Diamond | Level 26

This is a very unclear request, but maybe this example is what you want? https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=graphref&docsetTarget=n14...

 

If not, please explain in more detail, what "Regression column following by Hba values" means.

 

Also, please consider using the more recent procedure PROC SGPLOT for plotting, it has more features and (usually) a simpler syntax.

--
Paige Miller
ballardw
Super User

"Flopped" is awful vague.

Are there errors in the log?: Post the code and log in a code box opened with the "<>" to maintain formatting of error messages.

No output? Post any log in a code box.

Unexpected output? Provide input data in the form of data step code pasted into a code box, the actual results and the expected results. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the "<>" icon or attached as text to show exactly what you have and that we can test code against.

 

 

In Proc Gplot when use a plot request like:

plot Reg*Base_Hba Reg*FolHba/overlay;

Reg would be the Y, vertical axis, variable. Is that what you intend?

 

Most plot options are controlled by SYMBOL statements to indicate connected, smoothed or regessed line values depending on Interpolation options. The default symbol statements are mostly intended for scatter plots.

 

Which is one reason to consider @PaigeMiller's suggestion because you specify the type of plot up front: Scatter, Series, Regression along with options not possible in Gplot at all.

 

I am going to guess that maybe something along these lines:

proc Sgplot data=gp2;
  Scatter x=Base_Hba y=FolHba/ group=reg;
run;

If you intend connected lines that would be Series plot with the same syntax. However you likely want to sort your data by Reg and the X axis variable. Otherwise the order of values makes for strange plots.

PaigeMiller
Diamond | Level 26

Also, what exactly do you mean by a "trend line"? Elsewhere you use the word "regression", but a "trend line" and "regression line" don't have to be the same thing.

--
Paige Miller

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

What is ANOVA?

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.

Discussion stats
  • 3 replies
  • 1110 views
  • 4 likes
  • 3 in conversation