<?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: SGPLOT with lines depicting interaction in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SGPLOT-with-lines-depicting-interaction/m-p/801084#M315248</link>
    <description>&lt;P&gt;I'm not really sure on the proc reg part, but I've kludged something together to kinda show what you're wanting...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample_for_mood2;
   infile datalines dlm='09'x; 
   input sleepreg	sex_happy_inter	happiness	sex	school_prop;
   datalines;                      
0.99379	0.00000	-0.22054	0	0
1.31911	0.52946	0.52946	1	0.75
0.43157	0.77946	0.77946	1	0
1.85374	-1.42054	-1.42054	1	0.2
0.79650	0.00000	0.35089	0	0.4285714286
0.71688	1.11279	1.11279	1	0
0.53411	0.49375	0.49375	1	0.7142857143
0.75846	-1.22054	-1.22054	1	0.5714285714
1.47524	0.00000	0.77946	0	0.8
0.95821	0.77946	0.77946	1	0.4285714286
0.84614	0.11279	0.11279	1	0.6666666667
0.06736	0.00000	1.44613	0	0
0.68801	0.00000	0.77946	0	0
1.77189	0.00000	0.02946	0	0.5
1.32406	0.77946	0.77946	1	0.7142857143
0.21170	0.77946	0.77946	1	1
3.71327	1.20803	1.20803	1	0.4285714286
1.79483	0.00000	0.17946	0	0.5
0.77272	0.00000	-0.34554	0	0.625
1.48909	0.00000	-1.22054	0	0.6
2.17360	0.00000	-1.38721	0	0
1.31587	-0.50625	-0.50625	1	0
0.18523	0.00000	-1.22054	0	0.6666666667
1.02759	-0.22054	-0.22054	1	1
1.03145	0.00000	-1.79197	0	0.5714285714
0.01925	-1.55387	-1.55387	1	1
1.22628	0.11279	0.11279	1	0.6666666667
1.39426	0.00000	-0.22054	0	0.5
0.36690	0.00000	-0.05387	0	0
2.10064	-1.36340	-1.36340	1	0.7142857143
0.63730	0.00000	0.61279	0	0
1.06912	0.00000	0.06517	0	0.7142857143
0.21987	0.11279	0.11279	1	0.8333333333
1.46393	0.00000	-0.88721	0	0.6666666667
2.14191	-0.22054	-0.22054	1	0.6666666667
1.79833	-0.02054	-0.02054	1	0.8
0.28731	0.57946	0.57946	1	0
0.80436	1.35089	1.35089	1	0.7142857143
0.45050	-0.22054	-0.22054	1	0.8333333333
0.57373	0.00000	-0.97054	0	0
0.84570	0.00000	0.11279	0	0
0.85744	0.00000	-0.50625	0	0
1.59275	0.37946	0.37946	1	0.8
1.73977	-0.72054	-0.72054	1	0
0.13712	-0.22054	-0.22054	1	0
1.11154	0.00000	0.02946	0	0.625
2.52446	0.00000	1.17946	0	0.6
0.71264	0.00000	-0.79197	0	0.4285714286
0.84820	0.00000	-0.42054	0	0.2
;

proc sort data=sample_for_mood2;
by sex happiness;
run;

/*analysis*/
Proc reg data=sample_for_mood2 plots=none noprint;
 model sleepreg=happiness Sex sex_happy_inter school_prop  / VIF clb stb;
 output out=reg_out_data p=pred ucl=upper lcl=lower;;
 run;quit;
 
proc format;
value sexes
0=Female
1=Male
;
run;
 
proc sgplot data=reg_out_data;
format sex sexes.;
label happiness='Happiness (centered)';
label pred='Sleep regularity';
styleattrs datacontrastcolors=(hotpink blue);
series x=happiness y=pred / group=sex name="solid";
series x=happiness y=upper / group=sex lineattrs=(pattern=shortdash);
series x=happiness y=lower / group=sex lineattrs=(pattern=shortdash);
yaxis values=(-1 to 3 by 1);
xaxis values=(-2 to 2 by 1);
keylegend "solid" / position=top;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="GraphGuy_0-1646836439520.png" style="width: 721px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69282i0520D0ECADECF658/image-dimensions/721x546?v=v2" width="721" height="546" role="button" title="GraphGuy_0-1646836439520.png" alt="GraphGuy_0-1646836439520.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 09 Mar 2022 14:34:29 GMT</pubDate>
    <dc:creator>GraphGuy</dc:creator>
    <dc:date>2022-03-09T14:34:29Z</dc:date>
    <item>
      <title>SGPLOT with lines depicting interaction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SGPLOT-with-lines-depicting-interaction/m-p/800949#M315168</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I am interested in using SGPLOT to produce a line graph that depicts an interaction between happiness and sex on sleep regularity (with one line per sex). I used proc reg to perform the analysis. Below is code for a sample of my data (total N=600, sample n = 49) and the proc reg analysis:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*input data*/
data FFS_Act.sample_for_mood2;
   infile datalines; 
   input sleepreg	sex_happy_inter	happiness	sex	school_prop;
   datalines;                      
0.99379	0.00000	-0.22054	0	0
1.31911	0.52946	0.52946	1	0.75
0.43157	0.77946	0.77946	1	0
1.85374	-1.42054	-1.42054	1	0.2
0.79650	0.00000	0.35089	0	0.4285714286
0.71688	1.11279	1.11279	1	0
0.53411	0.49375	0.49375	1	0.7142857143
0.75846	-1.22054	-1.22054	1	0.5714285714
1.47524	0.00000	0.77946	0	0.8
0.95821	0.77946	0.77946	1	0.4285714286
0.84614	0.11279	0.11279	1	0.6666666667
0.06736	0.00000	1.44613	0	0
0.68801	0.00000	0.77946	0	0
1.77189	0.00000	0.02946	0	0.5
1.32406	0.77946	0.77946	1	0.7142857143
0.21170	0.77946	0.77946	1	1
3.71327	1.20803	1.20803	1	0.4285714286
1.79483	0.00000	0.17946	0	0.5
0.77272	0.00000	-0.34554	0	0.625
1.48909	0.00000	-1.22054	0	0.6
2.17360	0.00000	-1.38721	0	0
1.31587	-0.50625	-0.50625	1	0
0.18523	0.00000	-1.22054	0	0.6666666667
1.02759	-0.22054	-0.22054	1	1
1.03145	0.00000	-1.79197	0	0.5714285714
0.01925	-1.55387	-1.55387	1	1
1.22628	0.11279	0.11279	1	0.6666666667
1.39426	0.00000	-0.22054	0	0.5
0.36690	0.00000	-0.05387	0	0
2.10064	-1.36340	-1.36340	1	0.7142857143
0.63730	0.00000	0.61279	0	0
1.06912	0.00000	0.06517	0	0.7142857143
0.21987	0.11279	0.11279	1	0.8333333333
1.46393	0.00000	-0.88721	0	0.6666666667
2.14191	-0.22054	-0.22054	1	0.6666666667
1.79833	-0.02054	-0.02054	1	0.8
0.28731	0.57946	0.57946	1	0
0.80436	1.35089	1.35089	1	0.7142857143
0.45050	-0.22054	-0.22054	1	0.8333333333
0.57373	0.00000	-0.97054	0	0
0.84570	0.00000	0.11279	0	0
0.85744	0.00000	-0.50625	0	0
1.59275	0.37946	0.37946	1	0.8
1.73977	-0.72054	-0.72054	1	0
0.13712	-0.22054	-0.22054	1	0
1.11154	0.00000	0.02946	0	0.625
2.52446	0.00000	1.17946	0	0.6
0.71264	0.00000	-0.79197	0	0.4285714286
0.84820	0.00000	-0.42054	0	0.2
;

/*analysis*/
Proc reg data=FFS_Act.sample_for_mood2 plots=none;
 model sleepreg= happiness Sex sex_happy_inter school_prop  / VIF clb stb;run;quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Below is an example of what I want the chart to look like (this was created on the full and not the sample dataset, but the idea is the same):&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="confooseddesi89_1-1646777634538.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69263i950599D44AF9F9D5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="confooseddesi89_1-1646777634538.png" alt="confooseddesi89_1-1646777634538.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The only difference is that instead of the dotted lines, I would prefer 95% shaded confidence bands for each of the lines. Can anyone help?&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2022 22:14:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SGPLOT-with-lines-depicting-interaction/m-p/800949#M315168</guid>
      <dc:creator>confooseddesi89</dc:creator>
      <dc:date>2022-03-08T22:14:45Z</dc:date>
    </item>
    <item>
      <title>Re: SGPLOT with lines depicting interaction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SGPLOT-with-lines-depicting-interaction/m-p/800953#M315170</link>
      <description>&lt;P&gt;Something similar to this perhaps?&lt;/P&gt;
&lt;PRE&gt;
proc sgplot data=have;
   reg x=happiness y=sleepreg/ group=sex nomarkers
    clm clmtransparency=.3;
run;&lt;/PRE&gt;
&lt;P&gt;Please don't provide libraries in data set names. I am not going to make a library to run your code. Have is a generic name for data, use your data set name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can't tell from your description if you wanted an interval for the Mean (the CLM) or individual observations, which would be CLI. If you want a band representing the CLI values then you would use the Reg procedure to capture the estimates for the upper and lower bounds and use a BAND plot to overlay the Reg line only plot.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2022 22:32:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SGPLOT-with-lines-depicting-interaction/m-p/800953#M315170</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-08T22:32:48Z</dc:date>
    </item>
    <item>
      <title>Re: SGPLOT with lines depicting interaction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SGPLOT-with-lines-depicting-interaction/m-p/801084#M315248</link>
      <description>&lt;P&gt;I'm not really sure on the proc reg part, but I've kludged something together to kinda show what you're wanting...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample_for_mood2;
   infile datalines dlm='09'x; 
   input sleepreg	sex_happy_inter	happiness	sex	school_prop;
   datalines;                      
0.99379	0.00000	-0.22054	0	0
1.31911	0.52946	0.52946	1	0.75
0.43157	0.77946	0.77946	1	0
1.85374	-1.42054	-1.42054	1	0.2
0.79650	0.00000	0.35089	0	0.4285714286
0.71688	1.11279	1.11279	1	0
0.53411	0.49375	0.49375	1	0.7142857143
0.75846	-1.22054	-1.22054	1	0.5714285714
1.47524	0.00000	0.77946	0	0.8
0.95821	0.77946	0.77946	1	0.4285714286
0.84614	0.11279	0.11279	1	0.6666666667
0.06736	0.00000	1.44613	0	0
0.68801	0.00000	0.77946	0	0
1.77189	0.00000	0.02946	0	0.5
1.32406	0.77946	0.77946	1	0.7142857143
0.21170	0.77946	0.77946	1	1
3.71327	1.20803	1.20803	1	0.4285714286
1.79483	0.00000	0.17946	0	0.5
0.77272	0.00000	-0.34554	0	0.625
1.48909	0.00000	-1.22054	0	0.6
2.17360	0.00000	-1.38721	0	0
1.31587	-0.50625	-0.50625	1	0
0.18523	0.00000	-1.22054	0	0.6666666667
1.02759	-0.22054	-0.22054	1	1
1.03145	0.00000	-1.79197	0	0.5714285714
0.01925	-1.55387	-1.55387	1	1
1.22628	0.11279	0.11279	1	0.6666666667
1.39426	0.00000	-0.22054	0	0.5
0.36690	0.00000	-0.05387	0	0
2.10064	-1.36340	-1.36340	1	0.7142857143
0.63730	0.00000	0.61279	0	0
1.06912	0.00000	0.06517	0	0.7142857143
0.21987	0.11279	0.11279	1	0.8333333333
1.46393	0.00000	-0.88721	0	0.6666666667
2.14191	-0.22054	-0.22054	1	0.6666666667
1.79833	-0.02054	-0.02054	1	0.8
0.28731	0.57946	0.57946	1	0
0.80436	1.35089	1.35089	1	0.7142857143
0.45050	-0.22054	-0.22054	1	0.8333333333
0.57373	0.00000	-0.97054	0	0
0.84570	0.00000	0.11279	0	0
0.85744	0.00000	-0.50625	0	0
1.59275	0.37946	0.37946	1	0.8
1.73977	-0.72054	-0.72054	1	0
0.13712	-0.22054	-0.22054	1	0
1.11154	0.00000	0.02946	0	0.625
2.52446	0.00000	1.17946	0	0.6
0.71264	0.00000	-0.79197	0	0.4285714286
0.84820	0.00000	-0.42054	0	0.2
;

proc sort data=sample_for_mood2;
by sex happiness;
run;

/*analysis*/
Proc reg data=sample_for_mood2 plots=none noprint;
 model sleepreg=happiness Sex sex_happy_inter school_prop  / VIF clb stb;
 output out=reg_out_data p=pred ucl=upper lcl=lower;;
 run;quit;
 
proc format;
value sexes
0=Female
1=Male
;
run;
 
proc sgplot data=reg_out_data;
format sex sexes.;
label happiness='Happiness (centered)';
label pred='Sleep regularity';
styleattrs datacontrastcolors=(hotpink blue);
series x=happiness y=pred / group=sex name="solid";
series x=happiness y=upper / group=sex lineattrs=(pattern=shortdash);
series x=happiness y=lower / group=sex lineattrs=(pattern=shortdash);
yaxis values=(-1 to 3 by 1);
xaxis values=(-2 to 2 by 1);
keylegend "solid" / position=top;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="GraphGuy_0-1646836439520.png" style="width: 721px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69282i0520D0ECADECF658/image-dimensions/721x546?v=v2" width="721" height="546" role="button" title="GraphGuy_0-1646836439520.png" alt="GraphGuy_0-1646836439520.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Mar 2022 14:34:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SGPLOT-with-lines-depicting-interaction/m-p/801084#M315248</guid>
      <dc:creator>GraphGuy</dc:creator>
      <dc:date>2022-03-09T14:34:29Z</dc:date>
    </item>
    <item>
      <title>Re: SGPLOT with lines depicting interaction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SGPLOT-with-lines-depicting-interaction/m-p/801416#M315406</link>
      <description>&lt;P&gt;&amp;nbsp;ballardw, thanks for the recommendation about the library. I will remember that for future posts. No one has ever mentioned that to me before; I suppose they simply deleted the library name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you, the code worked well, with the proc format from GraphGuy. However I would like to make only the male line (sex=1) dotted, would you be able to help out? I only know how to change both lines. Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2022 18:21:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SGPLOT-with-lines-depicting-interaction/m-p/801416#M315406</guid>
      <dc:creator>confooseddesi89</dc:creator>
      <dc:date>2022-03-10T18:21:09Z</dc:date>
    </item>
  </channel>
</rss>

