<?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: proc sgplot- make line graphs with reference line. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-sgplot-make-line-graphs-with-reference-line/m-p/712011#M219421</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;is right. You have to store the first enrollment date instead of putting x=enrldt in lineparm. If you do that, you won't get 2 ref lines anymore. You could get first enrollment date using min in PROC SQL.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data enroll;&lt;BR /&gt;input usubjid $ enrldt :ddmmyy10.;&lt;BR /&gt;format enrldt yymmddd10.;&lt;BR /&gt;datalines;&lt;BR /&gt;bob 01-01-2021&lt;BR /&gt;alex 01-01-2021&lt;BR /&gt;sara 02-02-2021&lt;BR /&gt;chris 03-02-2021&lt;BR /&gt;patty 04-03-2021&lt;BR /&gt;jon 05-01-2021&lt;BR /&gt;dav 06-02-2021&lt;BR /&gt;justin 07-02-2021&lt;BR /&gt;cara 08-03-2021&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data enroll;&lt;BR /&gt;set enroll;&lt;BR /&gt;enrlfl='Y';&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc sort data=enroll out=enroll_sorted;&lt;BR /&gt;by usubjid enrldt;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc summary data = enroll nway;&lt;BR /&gt;class enrlfl enrldt;&lt;BR /&gt;format enrldt monyy7.;&lt;BR /&gt;output out=work.summary (drop=_type_);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;/* cumulative freq count*/&lt;BR /&gt;data work.toplot;&lt;BR /&gt;set work.summary;&lt;BR /&gt;by enrlfl enrldt;&lt;BR /&gt;retain count;&lt;BR /&gt;if first.enrlfl then count=_freq_;&lt;BR /&gt;else count+_freq_;&lt;BR /&gt;enrldt = intnx('month',enrldt,0,'B');&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc sql noprint;&lt;BR /&gt;select min(enrldt) into :first_enrollment&lt;BR /&gt;from enroll;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;=first_enrollment;&lt;/P&gt;
&lt;P&gt;/**graph**/&lt;BR /&gt;Proc sgplot data=work.toplot;&lt;BR /&gt;lineparm x=&amp;amp;first_enrollment y=1 slope=%eval(400/14)/ lineattrs=(pattern=mediumdash color=red thickness=1) transparency=0.4; &lt;BR /&gt;yaxis Values=(0 to 400 by 100) ;&lt;BR /&gt;series x=enrldt y=count/ markers;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="lrackley_0-1610940249975.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/53591i6D8F507DFC3D43E9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="lrackley_0-1610940249975.png" alt="lrackley_0-1610940249975.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 18 Jan 2021 03:24:18 GMT</pubDate>
    <dc:creator>tarheel13</dc:creator>
    <dc:date>2021-01-18T03:24:18Z</dc:date>
    <item>
      <title>proc sgplot- make line graphs with reference line.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sgplot-make-line-graphs-with-reference-line/m-p/712000#M219416</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;new to SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to make a line graph.&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. x-axis are dates (daily levels),&lt;/P&gt;&lt;P&gt;2. y-axis are cumulative frequency of subjects starting at 0 and with a maximum value of 400.&lt;/P&gt;&lt;P&gt;3. add a reference line (red dash-line). starts from "0" (y-axis) and the first date (variable="enrldt",x-axis) up to the fixed value of "400" in 14days (see "want" example below).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;current output (not sure why there's 2 reference line in red. Want "subects" to start from 0):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HitmonTran_1-1610927668019.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/53589i40F37C5A80AD436D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="HitmonTran_1-1610927668019.png" alt="HitmonTran_1-1610927668019.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;want (reference line up to 400 within 14day time frame from the first date (variable="enrldt"):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HitmonTran_0-1610926925028.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/53588iF5A72013EB949D05/image-size/medium?v=v2&amp;amp;px=400" role="button" title="HitmonTran_0-1610926925028.png" alt="HitmonTran_0-1610926925028.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data (example data below will not match to data in graph):&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;usubjid   enrldt
bob        01-01-2021
alex       01-01-2021
sara       02-02-2021
chris      03-02-2021
patty      04-03-2021
jon        05-01-2021
dav        06-02-2021
justin     07-02-2021
cara       08-03-2021&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;current code (not outputting the way I want it to):&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=adam.adsl out=adsl(keep=usubjid subjid enrlfl enrldt trt: age siteid);
	by usubjid enrldt;
	where enrlfl='Y';
run;
 
proc summary data = adsl nway;
   class enrlfl enrldt;
   format enrldt monyy7.;
   output out=work.summary (drop=_type_);
run;

/* cumulative freq count*/
data work.toplot;
   set work.summary;
   by enrlfl enrldt;
   retain count;
   if first.enrlfl then count=_freq_;
   else count+_freq_;
   enrldt = intnx('month',enrldt,0,'B');
run;

/**graph**/
Proc sgplot data=work.toplot;
   lineparm x=enrldt y=1 slope=%eval(400/14)/ lineattrs=(pattern=mediumdash color=red thickness=1) transparency=0.4; 
   yaxis Values=(0 to 400 by 100) ;
   
  XAXIS DISPLAY=(enrldt);
  YAXIS DISPLAY=(Cumulative Freq);&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2021 02:53:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sgplot-make-line-graphs-with-reference-line/m-p/712000#M219416</guid>
      <dc:creator>HitmonTran</dc:creator>
      <dc:date>2021-01-18T02:53:58Z</dc:date>
    </item>
    <item>
      <title>Re: proc sgplot- make line graphs with reference line.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sgplot-make-line-graphs-with-reference-line/m-p/712003#M219417</link>
      <description>&lt;P&gt;Without data or the complete plot code there is no way to tell exactly why you are getting two reference lines.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think that you may want to set a single value for X of the lineparm.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You do not show any attempt to determine the "earliest" enrldt. The manipulation of that variable in the data step is currently going to give you value for the start of each month that appears in your data. So you need to consider that in your summary. IF you want to have an actual x of enrldt for other bits of your plot then perhaps make a new variable, possibly only on the first value of enrlfl, with the desired value of x for the line parm.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2021 01:45:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sgplot-make-line-graphs-with-reference-line/m-p/712003#M219417</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-01-18T01:45:22Z</dc:date>
    </item>
    <item>
      <title>Re: proc sgplot- make line graphs with reference line.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sgplot-make-line-graphs-with-reference-line/m-p/712008#M219419</link>
      <description>i edited my post with sample data, thanks you ballardw.</description>
      <pubDate>Mon, 18 Jan 2021 02:55:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sgplot-make-line-graphs-with-reference-line/m-p/712008#M219419</guid>
      <dc:creator>HitmonTran</dc:creator>
      <dc:date>2021-01-18T02:55:30Z</dc:date>
    </item>
    <item>
      <title>Re: proc sgplot- make line graphs with reference line.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sgplot-make-line-graphs-with-reference-line/m-p/712011#M219421</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;is right. You have to store the first enrollment date instead of putting x=enrldt in lineparm. If you do that, you won't get 2 ref lines anymore. You could get first enrollment date using min in PROC SQL.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data enroll;&lt;BR /&gt;input usubjid $ enrldt :ddmmyy10.;&lt;BR /&gt;format enrldt yymmddd10.;&lt;BR /&gt;datalines;&lt;BR /&gt;bob 01-01-2021&lt;BR /&gt;alex 01-01-2021&lt;BR /&gt;sara 02-02-2021&lt;BR /&gt;chris 03-02-2021&lt;BR /&gt;patty 04-03-2021&lt;BR /&gt;jon 05-01-2021&lt;BR /&gt;dav 06-02-2021&lt;BR /&gt;justin 07-02-2021&lt;BR /&gt;cara 08-03-2021&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data enroll;&lt;BR /&gt;set enroll;&lt;BR /&gt;enrlfl='Y';&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc sort data=enroll out=enroll_sorted;&lt;BR /&gt;by usubjid enrldt;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc summary data = enroll nway;&lt;BR /&gt;class enrlfl enrldt;&lt;BR /&gt;format enrldt monyy7.;&lt;BR /&gt;output out=work.summary (drop=_type_);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;/* cumulative freq count*/&lt;BR /&gt;data work.toplot;&lt;BR /&gt;set work.summary;&lt;BR /&gt;by enrlfl enrldt;&lt;BR /&gt;retain count;&lt;BR /&gt;if first.enrlfl then count=_freq_;&lt;BR /&gt;else count+_freq_;&lt;BR /&gt;enrldt = intnx('month',enrldt,0,'B');&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc sql noprint;&lt;BR /&gt;select min(enrldt) into :first_enrollment&lt;BR /&gt;from enroll;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;=first_enrollment;&lt;/P&gt;
&lt;P&gt;/**graph**/&lt;BR /&gt;Proc sgplot data=work.toplot;&lt;BR /&gt;lineparm x=&amp;amp;first_enrollment y=1 slope=%eval(400/14)/ lineattrs=(pattern=mediumdash color=red thickness=1) transparency=0.4; &lt;BR /&gt;yaxis Values=(0 to 400 by 100) ;&lt;BR /&gt;series x=enrldt y=count/ markers;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="lrackley_0-1610940249975.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/53591i6D8F507DFC3D43E9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="lrackley_0-1610940249975.png" alt="lrackley_0-1610940249975.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2021 03:24:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sgplot-make-line-graphs-with-reference-line/m-p/712011#M219421</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2021-01-18T03:24:18Z</dc:date>
    </item>
  </channel>
</rss>

