<?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: Help needed with graphing data into SGPLOT with iteration through datastep in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Help-needed-with-graphing-data-into-SGPLOT-with-iteration/m-p/821197#M22935</link>
    <description>&lt;P&gt;Show a single sample graph, your explanation and data don't quite align especially with SAS terms. Specifically the reference lines....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.import;
    infile "/home/fkhurshed/Demo1/DummyData.csv"
	delimiter = "|"
	missover 
	dsd
	firstobs=2;
 
	informat DummyName $50.;
	informat wknr 2.;
	informat yr_range $9.;
	informat nodum 10.;
	
	format DummyName $50.;
	format wknr 2.;
	format yr_range $9.;
	format nodum 10.;
	
	input
	DummyName
	wknr
	yr_range
	nodum
	;
run;

/* Then this is how many distinct graphs we should produce: in this case 8 */
proc sql;
	create table imp_sg_tot as
    select distinct DummyName from work.import
	order by DummyName;
quit;

/* Data which should be used to show on graphs */
PROC SQL;
	CREATE table IMP_SG AS
		SELECT  *, max(wknr) as maxwk, min(wknr) as minwk, max(nodum) AS maxaant
 	FROM work.IMPORT 
	GROUP BY DummyName
	ORDER BY DummyName,yr_range,wknr;
QUIT;

/* 1 sgplot graph for each _n_ in dataset "IMP_SG_TOT" (n=1 to 8) from dataset "IMP_SG". */
/* On the horizontal axis there should show: wknr */
/* On the vertical axis: nodum */
/* Data should be grouped by(?) DummyName.  */
/* And all yr_ranges show as lines (different color/type lines) on this particular graph. */
/*  */
/* So.. for DummyName on _N_=1 (='Dum- &amp;amp; Dat') there should be 2 graphs like this:  */
/*  */
/* -first graph shows 5 lines for yr-ranges: 2016-2017, 2017-2018, 2018-2019, 2019-2020 and 2020-2021.  */
/* -and second graph shows only 1 line for yr-range: 2022-2023 */

proc sgplot data=imp_sg;
by dummyName;
series x=wknr y=nodum / group = yr_range;
refline minwk / axis=y;
refline maxaant / axis=y;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 30 Jun 2022 19:30:58 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2022-06-30T19:30:58Z</dc:date>
    <item>
      <title>Help needed with graphing data into SGPLOT with iteration through datastep</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Help-needed-with-graphing-data-into-SGPLOT-with-iteration/m-p/821195#M22934</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* HAVE */

/* First import the csv data file */
data work.import;
    infile "P:\TEMP\DummyData.csv"
	delimiter = "|"
	missover 
	dsd
	firstobs=2;
 
	informat DummyName $50.;
	informat wknr 2.;
	informat yr_range $9.;
	informat nodum 10.;
	
	format DummyName $50.;
	format wknr 2.;
	format yr_range $9.;
	format nodum 10.;
	
	input
	DummyName
	wknr
	yr_range
	nodum
	;
run;

/* Then this is how many distinct graphs we should produce: in this case 8 */
proc sql;
	create table imp_sg_tot as
    select distinct DummyName from work.import
	order by DummyName;
quit;

/* Data which should be used to show on graphs */
PROC SQL;
	CREATE table IMP_SG AS
		SELECT  *, max(wknr) as maxwk, min(wknr) as minwk, max(nodum) AS maxaant
 	FROM work.IMPORT 
	GROUP BY DummyName,yr_range
	ORDER BY DummyName,yr_range,wknr;
QUIT;

/* WANT */

/* 
1 sgplot graph for each _n_ in dataset "IMP_SG_TOT" (n=1 to 8) from dataset "IMP_SG".
On the horizontal axis there should show: wknr
On the vertical axis: nodum
Data should be grouped by(?) DummyName. 
And all yr_ranges show as lines (different color/type lines) on this particular graph.

So.. for DummyName on _N_=1 (='Dum- &amp;amp; Dat') there should be 2 graphs like this: 

-first graph shows 5 lines for yr-ranges: 2016-2017, 2017-2018, 2018-2019, 2019-2020 and 2020-2021. 
-and second graph shows only 1 line for yr-range: 2022-2023

I don't want to use sgpanel. Only sgplot. Is this possible? 
I hope you guys understand what i mean... and above all: i hope someone can help me out with graphing! 
I really don't have that much experience with graphing the data.... :-( 
Thanks in Advance! 
*/
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Well it says it all in my SAS-code actually...&lt;/P&gt;
&lt;P&gt;I hope someone can help me out! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And the data i use is as attachment: csv-file&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sorry.. forget something!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why I am making extra columns (with max &amp;amp; min wknr and max nodum) is because I want the graphs to show the min and max wknr on the axis automatically based on this column values! Idem. for the max nodum on the vertical axis.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope you guys/girls understand what I mean. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit2:&amp;nbsp;&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp; yes, I mean they are limits of the axis! Thank you!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;that are the graphs I want yes! But only 2 graphs per DummyName:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) with all the years (except for 2022-2023) (so you get 5 vlines in 1 graph)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) only 2022-2023 year (so you get 1 vline in 1 graph)&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;This is my picture - please note: it contains only year 2016-2017, but it must contain 5 vlines/groups of years.&lt;/P&gt;
&lt;P&gt;Hopefully it is clear to you guys now? If not, please let me know! I will clear it more for you if needed. I'm still learning... &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="example.PNG" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72865i549A4F3016169895/image-size/large?v=v2&amp;amp;px=999" role="button" title="example.PNG" alt="example.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jun 2022 23:00:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Help-needed-with-graphing-data-into-SGPLOT-with-iteration/m-p/821195#M22934</guid>
      <dc:creator>SAS_Question</dc:creator>
      <dc:date>2022-06-30T23:00:02Z</dc:date>
    </item>
    <item>
      <title>Re: Help needed with graphing data into SGPLOT with iteration through datastep</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Help-needed-with-graphing-data-into-SGPLOT-with-iteration/m-p/821197#M22935</link>
      <description>&lt;P&gt;Show a single sample graph, your explanation and data don't quite align especially with SAS terms. Specifically the reference lines....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.import;
    infile "/home/fkhurshed/Demo1/DummyData.csv"
	delimiter = "|"
	missover 
	dsd
	firstobs=2;
 
	informat DummyName $50.;
	informat wknr 2.;
	informat yr_range $9.;
	informat nodum 10.;
	
	format DummyName $50.;
	format wknr 2.;
	format yr_range $9.;
	format nodum 10.;
	
	input
	DummyName
	wknr
	yr_range
	nodum
	;
run;

/* Then this is how many distinct graphs we should produce: in this case 8 */
proc sql;
	create table imp_sg_tot as
    select distinct DummyName from work.import
	order by DummyName;
quit;

/* Data which should be used to show on graphs */
PROC SQL;
	CREATE table IMP_SG AS
		SELECT  *, max(wknr) as maxwk, min(wknr) as minwk, max(nodum) AS maxaant
 	FROM work.IMPORT 
	GROUP BY DummyName
	ORDER BY DummyName,yr_range,wknr;
QUIT;

/* 1 sgplot graph for each _n_ in dataset "IMP_SG_TOT" (n=1 to 8) from dataset "IMP_SG". */
/* On the horizontal axis there should show: wknr */
/* On the vertical axis: nodum */
/* Data should be grouped by(?) DummyName.  */
/* And all yr_ranges show as lines (different color/type lines) on this particular graph. */
/*  */
/* So.. for DummyName on _N_=1 (='Dum- &amp;amp; Dat') there should be 2 graphs like this:  */
/*  */
/* -first graph shows 5 lines for yr-ranges: 2016-2017, 2017-2018, 2018-2019, 2019-2020 and 2020-2021.  */
/* -and second graph shows only 1 line for yr-range: 2022-2023 */

proc sgplot data=imp_sg;
by dummyName;
series x=wknr y=nodum / group = yr_range;
refline minwk / axis=y;
refline maxaant / axis=y;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Jun 2022 19:30:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Help-needed-with-graphing-data-into-SGPLOT-with-iteration/m-p/821197#M22935</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-06-30T19:30:58Z</dc:date>
    </item>
    <item>
      <title>Re: Help needed with graphing data into SGPLOT with iteration through datastep</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Help-needed-with-graphing-data-into-SGPLOT-with-iteration/m-p/821199#M22936</link>
      <description>&lt;P&gt;I would suggest that you start with this and see if anything actually needs changing:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sgplot data=work.imp_sg;
   by dummyname notsorted; 
   scatter x=wknr y=nodum/group=yr_range;
run;

&lt;/PRE&gt;
&lt;P&gt;Actually you may not even need the other data sets but might need either NOTSORTED on the By statement if you use the first set or sort the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you use a By group processing the default behavior for Sgplot is that the axis ranges are calculated for each graph. So your max and min values may not be needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your really did not specify what type of graph you expected, series, scatter, needle, vector or something else. The bit about those values on the axis were not very clear. Were they supposed to be limits of the axis, special tick marks added, reference lines or what?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jun 2022 19:34:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Help-needed-with-graphing-data-into-SGPLOT-with-iteration/m-p/821199#M22936</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-06-30T19:34:44Z</dc:date>
    </item>
    <item>
      <title>Re: Help needed with graphing data into SGPLOT with iteration through datastep</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Help-needed-with-graphing-data-into-SGPLOT-with-iteration/m-p/821210#M22937</link>
      <description>&lt;P&gt;Sorry guys for being so messy with the data and not being so clear! &lt;BR /&gt;I will try to clear my text by putting an examples of graph I want..hopefully it will clear things out. &lt;BR /&gt;Please see my Opening Post! I will add it there, just a moment!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And thank you guys for helping out!!!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jun 2022 22:53:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Help-needed-with-graphing-data-into-SGPLOT-with-iteration/m-p/821210#M22937</guid>
      <dc:creator>SAS_Question</dc:creator>
      <dc:date>2022-06-30T22:53:00Z</dc:date>
    </item>
    <item>
      <title>Re: Help needed with graphing data into SGPLOT with iteration through datastep</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Help-needed-with-graphing-data-into-SGPLOT-with-iteration/m-p/821485#M22943</link>
      <description>&lt;P&gt;If the code I posted seems correct, just add a WHERE statement to filter the years of interest.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jul 2022 15:24:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Help-needed-with-graphing-data-into-SGPLOT-with-iteration/m-p/821485#M22943</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-07-04T15:24:19Z</dc:date>
    </item>
  </channel>
</rss>

