<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: A question about  proc gplot in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/A-question-about-proc-gplot/m-p/16509#M327</link>
    <description>I would recommend using just a simple 'by' statement, rather than going to the trouble of looping through all the id's and calling a macro each time.&lt;BR /&gt;
&lt;BR /&gt;
I would do it something like this...&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data temp;&lt;BR /&gt;
input ID $ score section;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 90 1&lt;BR /&gt;
1 89 1&lt;BR /&gt;
1 92 1&lt;BR /&gt;
1 70 2&lt;BR /&gt;
1 65 2&lt;BR /&gt;
1 80 2&lt;BR /&gt;
1 88 3&lt;BR /&gt;
1 70 3&lt;BR /&gt;
1 75 3&lt;BR /&gt;
2 95 1&lt;BR /&gt;
2 88 1&lt;BR /&gt;
2 93 1&lt;BR /&gt;
2 87 2&lt;BR /&gt;
2 83 2&lt;BR /&gt;
2 70 2&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
create table avg_anno as&lt;BR /&gt;
select unique id, avg(score) as avg_score&lt;BR /&gt;
from temp group by id;&lt;BR /&gt;
quit; run;&lt;BR /&gt;
data avg_anno; set avg_anno;&lt;BR /&gt;
length function $8;&lt;BR /&gt;
xsys='1'; ysys='2'; hsys='3';&lt;BR /&gt;
function='move'; x=0; y=avg_score; output;&lt;BR /&gt;
function='draw'; x=100; color='blue'; size=.1; output;&lt;BR /&gt;
function='label'; position='a'; size=.;&lt;BR /&gt;
 text='avg = '||trim(left(put(avg_score,comma10.1))); output;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
goptions gunit=pct htitle=5 htext=3.5;&lt;BR /&gt;
&lt;BR /&gt;
AXIS1 ORDER=(0 TO 4 BY 1) minor=none offset=(0,0);&lt;BR /&gt;
axis2 order=(50 to 100 by 10) minor=none offset=(0,0);&lt;BR /&gt;
&lt;BR /&gt;
symbol value=circle h=2 i=none color=red;&lt;BR /&gt;
&lt;BR /&gt;
PROC GPLOT DATA=temp;&lt;BR /&gt;
by id;&lt;BR /&gt;
PLOT score*section / haxis=axis1 vaxis=axis2 anno=avg_anno;&lt;BR /&gt;
RUN;</description>
    <pubDate>Fri, 15 Oct 2010 14:04:46 GMT</pubDate>
    <dc:creator>GraphGuy</dc:creator>
    <dc:date>2010-10-15T14:04:46Z</dc:date>
    <item>
      <title>A question about  proc gplot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/A-question-about-proc-gplot/m-p/16508#M326</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
Please see the below for my data:&lt;BR /&gt;
data temp;&lt;BR /&gt;
   input ID $ score section;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 90 1&lt;BR /&gt;
1 89 1&lt;BR /&gt;
1 92 1&lt;BR /&gt;
1 70 2&lt;BR /&gt;
1 65 2&lt;BR /&gt;
1 80 2&lt;BR /&gt;
1 88 3&lt;BR /&gt;
1 70 3&lt;BR /&gt;
1 75 3&lt;BR /&gt;
2 95 1&lt;BR /&gt;
2 88 1&lt;BR /&gt;
2 93 1&lt;BR /&gt;
2 87 2&lt;BR /&gt;
2 83 2&lt;BR /&gt;
2 70 2&lt;BR /&gt;
***more data;&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
I want to get the plot of score by section for each ID, that is,one page for each ID, and draw a line to label the mean. I have many many IDs so I used a macro to do it. Here is my code:&lt;BR /&gt;
&lt;BR /&gt;
%macro test(id);&lt;BR /&gt;
&lt;BR /&gt;
data temp2;&lt;BR /&gt;
   set temp;&lt;BR /&gt;
   if ID="&amp;amp;id";&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
PROC MEANS DATA=temp2 NOPRINT N MEAN STD;&lt;BR /&gt;
    VAR score;&lt;BR /&gt;
	CLASS section;&lt;BR /&gt;
	OUTPUT OUT=summary N=TOT MEAN=mean_score STD=std_score;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
data summary2;&lt;BR /&gt;
   set summary;&lt;BR /&gt;
   if section='' then delete;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sort data=summary2;&lt;BR /&gt;
   by section;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
DATA _NULL_;&lt;BR /&gt;
    SET summary2;&lt;BR /&gt;
	CALL SYMPUT('a'!!TRIM(LEFT(_N_)),mean_score);&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
DATA anno_data;&lt;BR /&gt;
    %SYSTEM(2,2);&lt;BR /&gt;
	%ANNOMAC;&lt;BR /&gt;
    %LINE(0.7,&amp;amp;a1,1.3,&amp;amp;a1,BLACK,1,4);&lt;BR /&gt;
    %LINE(1.7,&amp;amp;a2,2.3,&amp;amp;a2,BLACK,1,4);&lt;BR /&gt;
    %LINE(2.7,&amp;amp;a3,3.3,&amp;amp;a3,BLACK,1,4);&lt;BR /&gt;
   RUN;&lt;BR /&gt;
&lt;BR /&gt;
AXIS1 ORDER=(0 TO 4 BY 1);&lt;BR /&gt;
PROC GPLOT DATA=temp2 ANNO=anno_data;&lt;BR /&gt;
    PLOT score*section / haxis=axis1;&lt;BR /&gt;
RUN;&lt;BR /&gt;
QUIT;&lt;BR /&gt;
&lt;BR /&gt;
%mend;&lt;BR /&gt;
&lt;BR /&gt;
%test(1);&lt;BR /&gt;
%test(2);&lt;BR /&gt;
&lt;BR /&gt;
The first plot (ID=1) is correct. For ID=2, the data doesn't have section 3, but sas still draw a line at y=77.6, I guess this is the mean for a3 when ID=1, so it seemed it passed the value of last run. I don't understand how this happen. Thanks in advance.&lt;BR /&gt;
&lt;BR /&gt;
Lu</description>
      <pubDate>Wed, 13 Oct 2010 19:47:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/A-question-about-proc-gplot/m-p/16508#M326</guid>
      <dc:creator>lueryy2000</dc:creator>
      <dc:date>2010-10-13T19:47:00Z</dc:date>
    </item>
    <item>
      <title>Re: A question about  proc gplot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/A-question-about-proc-gplot/m-p/16509#M327</link>
      <description>I would recommend using just a simple 'by' statement, rather than going to the trouble of looping through all the id's and calling a macro each time.&lt;BR /&gt;
&lt;BR /&gt;
I would do it something like this...&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data temp;&lt;BR /&gt;
input ID $ score section;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 90 1&lt;BR /&gt;
1 89 1&lt;BR /&gt;
1 92 1&lt;BR /&gt;
1 70 2&lt;BR /&gt;
1 65 2&lt;BR /&gt;
1 80 2&lt;BR /&gt;
1 88 3&lt;BR /&gt;
1 70 3&lt;BR /&gt;
1 75 3&lt;BR /&gt;
2 95 1&lt;BR /&gt;
2 88 1&lt;BR /&gt;
2 93 1&lt;BR /&gt;
2 87 2&lt;BR /&gt;
2 83 2&lt;BR /&gt;
2 70 2&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
create table avg_anno as&lt;BR /&gt;
select unique id, avg(score) as avg_score&lt;BR /&gt;
from temp group by id;&lt;BR /&gt;
quit; run;&lt;BR /&gt;
data avg_anno; set avg_anno;&lt;BR /&gt;
length function $8;&lt;BR /&gt;
xsys='1'; ysys='2'; hsys='3';&lt;BR /&gt;
function='move'; x=0; y=avg_score; output;&lt;BR /&gt;
function='draw'; x=100; color='blue'; size=.1; output;&lt;BR /&gt;
function='label'; position='a'; size=.;&lt;BR /&gt;
 text='avg = '||trim(left(put(avg_score,comma10.1))); output;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
goptions gunit=pct htitle=5 htext=3.5;&lt;BR /&gt;
&lt;BR /&gt;
AXIS1 ORDER=(0 TO 4 BY 1) minor=none offset=(0,0);&lt;BR /&gt;
axis2 order=(50 to 100 by 10) minor=none offset=(0,0);&lt;BR /&gt;
&lt;BR /&gt;
symbol value=circle h=2 i=none color=red;&lt;BR /&gt;
&lt;BR /&gt;
PROC GPLOT DATA=temp;&lt;BR /&gt;
by id;&lt;BR /&gt;
PLOT score*section / haxis=axis1 vaxis=axis2 anno=avg_anno;&lt;BR /&gt;
RUN;</description>
      <pubDate>Fri, 15 Oct 2010 14:04:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/A-question-about-proc-gplot/m-p/16509#M327</guid>
      <dc:creator>GraphGuy</dc:creator>
      <dc:date>2010-10-15T14:04:46Z</dc:date>
    </item>
    <item>
      <title>Re: A question about  proc gplot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/A-question-about-proc-gplot/m-p/16510#M328</link>
      <description>Thank you very much. Although it is not what I expected, it is still a good way to do. Thanks again.&lt;BR /&gt;
Lu</description>
      <pubDate>Fri, 15 Oct 2010 15:38:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/A-question-about-proc-gplot/m-p/16510#M328</guid>
      <dc:creator>lueryy2000</dc:creator>
      <dc:date>2010-10-15T15:38:54Z</dc:date>
    </item>
  </channel>
</rss>

