Programming the statistical procedures from SAS

How to Create Some Specific Graphs on SAS

Reply
Super Contributor
Posts: 381

How to Create Some Specific Graphs on SAS

Following reports are created on Excel. My purpose is to learn how i can create these reports by SAS code or on EG.

 

I just want you to guide me i will spare time Smiley Happy

 

Is it possible to create ROC Curve by using Line Plot and Scatter Plot. Maybe i have to use ANNOVA graphic’s on EG.

 

Roc&Curve.png

If i create the Traffic Lights Report by using Line Plot how i can add the colors. I created the colors on table by using Proc Report through IF-ELSE Condition now i have to add colors on Line Plot.

 

Traffic.png

 

I think I should use Bar-Line graphic for following graphic but there is a limit on Bar statement.

 

Graphşc.png

 

I guess i can create following report on EG in an easy way.

 

Line3.png

 

This was the first time i tried to create following reports. So i haven’t got many information related to these reports i f i get some helps it will be beneficial for me.

 

Could you lead me, please ?

 

Thank you.

Super User
Super User
Posts: 7,565

Re: How to Create Some Specific Graphs on SAS

Go over to this blog:

http://blogs.sas.com/content/graphicallyspeaking/

 

And look through the thousands of examples, with code in both GTL and sgplot.  Everything you could possible want to know about graphs is there.

 

SAS Super FREQ
Posts: 3,554

Re: How to Create Some Specific Graphs on SAS

You can create ROC plots automatically by using PROC LOGISTIC.

ods graphics on;
proc logistic data=sashelp.class plots(only)=roc;
   model sex = height / outroc=roc;
run;

If you need to do something fancy, the OUTROC= option writes the ROC data to an output data set.

 

SAS Super FREQ
Posts: 3,554

Re: How to Create Some Specific Graphs on SAS

The non-ROC plots are merely graphs that overlay standard elements such as bars, lines, reference lines, bands, etc.

 

Post your particular questions along with sample data to the SAS/GRAPH and ODS Graphics Support Community and say "I want to learn how to create this graph by using PROC SGPLOT."  They are easy to create once you learn the basic techniques.

Super Contributor
Posts: 381

Re: How to Create Some Specific Graphs on SAS

Thank you,

During this period you helped me a lot and i think you are expert of SAS. I asked my question SAS/GRAPH and ODS Graphics Support Community page as you said. I've already tried proc logistic but i didn't get the desired result which Excel generated. MM and EM generate ROC Curve easily i wonder how i can see the code behind of program maybe i can get some helps. I think it is hard to discover how to create these report in the beginning ?

 

Thanks again

SAS Super FREQ
Posts: 3,554

Re: How to Create Some Specific Graphs on SAS

You are welcome. I'm sure that it won't be long before you that you are making awesome graphs in SAS.

 

The quickest way to get a helpful response is to provide sample data. Often someone will be able to respond with the exact procedure and statements that you need. Since you are interesting in creating graphs, see the article "How to ask a good question about graphing in SAS"

Super Contributor
Posts: 381

Re: How to Create Some Specific Graphs on SAS

Rick,

Your replies are always very accurate. I can receive the information i need from you. I will consider your suggestion. As far as i understand the main point is to provide sample data.

Thanks.

Super User
Posts: 18,589

Re: How to Create Some Specific Graphs on SAS

Look at robslink.com for a lot of graphs and the full code/data behind them.
Super Contributor
Posts: 381

Re: How to Create Some Specific Graphs on SAS

Hello Reeza,

 

This is the first time you answered without being angry Smiley Happy also it is beneficial for me.

 

Thank you.

Super User
Posts: 18,589

Re: How to Create Some Specific Graphs on SAS

I'm never angry...
Community Manager
Posts: 2,844

Re: How to Create Some Specific Graphs on SAS

@Reeza never strikes me as anything but helpful and nice, but maybe we need to introduce a new badge to the communities!

 

angry.png

Super Contributor
Posts: 381

Re: How to Create Some Specific Graphs on SAS

I created the Roc Curve by using PROC GPLOT procedure. I hope it is the correct method.

 

 

PROC GPLOT DATA = <dataset>;
PLOT column1* column2  column2*column2/
 OVERLAY
	VAXIS=AXIS1

	HAXIS=AXIS2

FRAME	CFRAME=CXD2D2D2
	LVREF=1
	CVREF=BLACK
	AUTOVREF
	NOLEGEND
;
	FORMAT column2 PERCENT8.
		column1 PERCENT8.;
RUN; 
QUIT;

Thanks a lot.

 

SAS Employee
Posts: 245

Re: How to Create Some Specific Graphs on SAS

Given a data set with variables containing the sensitivity and specificity values (such as the OUTROC= data set from PROC LOGISTIC), these statements effectively reproduce the ROC graph produced by PROC LOGISTIC.  See the options in PROC SGPLOT if you want to makes alterations.

 

proc sgplot data=rocdata noautolegend aspect=1;
xaxis values=(0 to 1 by 0.25) grid offsetmin=.05 offsetmax=.05;
yaxis values=(0 to 1 by 0.25) grid offsetmin=.05 offsetmax=.05;
lineparm x=0 y=0 slope=1 / transparency=.7;
series x=_1mspec_ y=_sensit_;
run;

Super Contributor
Posts: 381

Re: How to Create Some Specific Graphs on SAS

Thanks a lot @StatDave_sas It's good to know this. 

 

I created my last posted report which has logbase10 Axises. I used th GPLOT procedure again. You can see the code as below.

 

PROC GPLOT DATA = <dataset>
PLOT Column2* Column1
Column1* Column1
Column3* Column1
/
 OVERLAY
 GRID
	VAXIS=AXIS1

	HAXIS=AXIS2

	FRAME CFRAME=CXD4D4D4
	CVREF=CX969696
	CHREF=CX969696

FRAME	NOLEGEND;
FORMAT Column2 PERCENT11.4
		Column1 PERCENT11.4;
RUN; 
QUIT;
Super Contributor
Posts: 381

Re: How to Create Some Specific Graphs on SAS

I created the traffic lights report by using Pattern and Areas option. You can see the code below

 

pattern1 v=s c=White;
pattern2 v=s c=Green;
pattern3 v=s c=yellow;
pattern4 v=s c=yellow;

 

PROC GPLOT DATA =<dataset>;
PLOT Column1* Column Column3* Column
Column2* Column Column4* Column/
 OVERLAY
	VAXIS=AXIS1

	HAXIS=AXIS2
	AREAS=1 
	AREAS=2 
	AREAS=3 
	AREAS=4
	AUTOVREF 
	
	HREVERSE
FRAME	 CFRAME=RED
LEGEND=LEGEND1
;
	FORMAT 
		Column1 PERCENT8.
		Column2 PERCENT8.
		Column3 PERCENT8.
		Column4 PERCENT8.;

RUN; 
QUIT;

 

On my third report, i would like to create both bars and lines. I'm working on EG and i'm also trying to use SAS codes but i couldn't create the both bars and both lines. Firstly, i tried to use PROC GCHART(Bar Chart on EG) i added the column1 into 'Column to chart' for horizontal axes and i added column1 and column2 into 'Sum of' which generated bars.By using this method i could create the bars which i wanted but i can't create the lines on PROC GHART. I also used PROC GBARLINE(Bar-Line on EG) i could create the lines and a bar but there is a bar limit on PROC GBARLINE for this reason i can't create two bars on PROC GBARLINE. I searched on google and some forums/blogs of SAS but i couldn't what i want. If somebody have knowledge about this can s/he share an example which includes two bars and three lines to help me, please ? I've already checked many procedure on google and some blogs. Seeing an example will be the best method for me to understand well.

 

Thank you.

Ask a Question
Discussion stats
  • 14 replies
  • 755 views
  • 9 likes
  • 6 in conversation