<?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: Finding the mean median and confidenceinterval of a data (in a graph) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-mean-median-and-confidenceinterval-of-a-data-in-a/m-p/853423#M337315</link>
    <description>&lt;P&gt;I suggest a few things:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Use PROC MEANS to compute the statistics you want&lt;/LI&gt;
&lt;LI&gt;Put the drug types on the Y axis, since the labels are so long.&lt;/LI&gt;
&lt;LI&gt;Use the SCATTER statement with the XERRORLOWER and XERRORUPPER options to display the mean and CL&lt;/LI&gt;
&lt;LI&gt;Use a second SCATTER statement to display the median&lt;/LI&gt;
&lt;/OL&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;                                          
infile datalines;                                   
input Drug_type $44. visit    treatment_duration  num_of_patients;
datalines; 
Cefalexin+Baclofen+Betahistine               1 120 15
Calcipotriol+Baclofen+Betahistine            1 164 10
Folic acid+Baclofen                          1 26  2 
Piriton+Baclofen                             1 30  5 
Fentanyl/Co-beneldopa+Baclofen+Betahistine   1 90  10
Folic acid+Baclofen                          1 26  33
Fentanyl/Co-beneldopa+Baclofen               1 35  50
Folic acid+Baclofen                          1 15  6 
Cefalexin+Baclofen                           1 11  1 
Fentanyl/Co-beneldopa+Baclofen               2 35  14
Allopurinol+Baclofen+Betahistine             2 300 25
Folic acid+Baclofen+Betahistine              2 27  30
Cefalexin+Baclofen                           2 110 17
Allopurinol+Baclofen+Betahistine             2 240 55
Cefalexin+Baclofen                           2 11  17
Folic acid+Baclofen                          2 26  33
Piriton+Baclofen                             3 77  9 
Folic acid+Baclofen+Betahistine              3 27  19
Allopurinol+Baclofen+Betahistine             3 105 16
Piriton+Baclofen                             3 210 8 
Cefalexin+Baclofen                           3 11  32
Piriton+Baclofen                             3 38  11
Cefalexin+Baclofen                           3 11  31
Cefalexin+Baclofen+Betahistine               3 200 20
Cefalexin+Baclofen                           3 11  10
Cefalexin+Baclofen                           4 11  4 
Fentanyl/Co-beneldopa+Baclofen               4 35  18
Diclofenac+Baclofen                          4 66  25
Diclofenac+Baclofen                          4 45  14
Fentanyl/Co-beneldopa+Baclofen               4 115 22
;

/* https://blogs.sas.com/content/iml/2019/10/09/statistic-error-bars-mean.html */
proc means data=have noprint;
   class drug_type;
   freq num_of_patients;
   var treatment_duration;
   output out=MeanOut Mean=Mean Median=Median lclm=LCLM uclm=UCLM;
run;

title "Mean and Median Treatment Length";
title2 "95% Confidence Interval for Mean";
proc sgplot data=MeanOut;
scatter y=drug_type x=Mean / xerrorlower=lclm xerrorupper=uclm
        legendlabel="Mean";
scatter y=drug_type x=Median / legendlabel="Median" markerattrs=(Symbol=Diamond);
xaxis label="Treatment Length";
yaxis display=(nolabel);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 12 Jan 2023 11:34:21 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2023-01-12T11:34:21Z</dc:date>
    <item>
      <title>Finding the mean median and confidenceinterval of a data (in a graph)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-mean-median-and-confidenceinterval-of-a-data-in-a/m-p/853292#M337254</link>
      <description>&lt;P&gt;Dear all,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if I have a data that looks like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;                                          
infile datalines;                                   
input Drug_type $44. visit 	treatment_duration 3. num_of_patients;
datalines; 
Cefalexin+Baclofen+Betahistine	            1 120 15
Calcipotriol+Baclofen+Betahistine	        1 164 10
Folic acid+Baclofen	                        1 26  2 
Piriton+Baclofen	                        1 30  5 
Fentanyl/Co-beneldopa+Baclofen+Betahistine	1 90  10
Folic acid+Baclofen	                        1 26  33
Fentanyl/Co-beneldopa+Baclofen	            1 35  50
Folic acid+Baclofen	                        1 15  6 
Cefalexin+Baclofen	                        1 11  1 
Fentanyl/Co-beneldopa+Baclofen	            2 35  14
Allopurinol+Baclofen+Betahistine	        2 300 25
Folic acid+Baclofen+Betahistine	            2 27  30
Cefalexin+Baclofen	                        2 110 17
Allopurinol+Baclofen+Betahistine	        2 240 55
Cefalexin+Baclofen	                        2 11  17
Folic acid+Baclofen	                        2 26  33
Piriton+Baclofen	                        3 77  9 
Folic acid+Baclofen+Betahistine	            3 27  19
Allopurinol+Baclofen+Betahistine	        3 105 16
Piriton+Baclofen	                        3 210 8 
Cefalexin+Baclofen	                        3 11  32
Piriton+Baclofen	                        3 38  11
Cefalexin+Baclofen	                        3 11  31
Cefalexin+Baclofen+Betahistine	            3 200 20
Cefalexin+Baclofen	                        3 11  10
Cefalexin+Baclofen	                        4 11  4 
Fentanyl/Co-beneldopa+Baclofen	            4 35  18
Diclofenac+Baclofen	                        4 66  25
Diclofenac+Baclofen	                        4 45  14
Fentanyl/Co-beneldopa+Baclofen	            4 115 22
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I wish to calculate the mean, median and confidence interval of the treatment duration showing this graphically. I was thinking of using boxplot but am not able to display all the 4 variables in the data. Can someone help? Maybe there is a better way to do this than using a boxplot&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jan 2023 16:55:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-mean-median-and-confidenceinterval-of-a-data-in-a/m-p/853292#M337254</guid>
      <dc:creator>Anita_n</dc:creator>
      <dc:date>2023-01-11T16:55:32Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the mean median and confidenceinterval of a data (in a graph)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-mean-median-and-confidenceinterval-of-a-data-in-a/m-p/853309#M337260</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/168930"&gt;@Anita_n&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I wish to calculate the mean, median and confidence interval of the treatment duration showing this graphically. I was thinking of using boxplot but am not able to display all the 4 variables in the data. Can someone help? Maybe there is a better way to do this than using a boxplot&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I don't know what you mean by "display all 4 variables in the data". What 4 variables are you talking about?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nevertheless, maybe this is helpful:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=have;
    vbox treatment_duration/group=drug_type meanattrs=(color=white symbol=asterisk);
run;
proc sgplot data=have;
    vbox treatment_duration/group=visit meanattrs=(color=white symbol=asterisk);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jan 2023 18:05:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-mean-median-and-confidenceinterval-of-a-data-in-a/m-p/853309#M337260</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-01-11T18:05:29Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the mean median and confidenceinterval of a data (in a graph)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-mean-median-and-confidenceinterval-of-a-data-in-a/m-p/853316#M337263</link>
      <description>&lt;P&gt;Something like this perhaps? Note that the data step was modified to run as some of the spaces in your datalines seem to be tab characters and when pasted into my editor did not align so generated invalid data errors.&lt;/P&gt;
&lt;P&gt;Boxplots generally don't display "confidence intervals" but the Interquartile Range as the upper/lower values of the box when enough values are present. Is that what you meant? If not then you may want to summarize data and use error bars with the confidence limits setting the lower and upper limits on a scatter plot.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;                                          
infile datalines;                                   
input Drug_type $44. visit    treatment_duration  num_of_patients;
datalines; 
Cefalexin+Baclofen+Betahistine               1 120 15
Calcipotriol+Baclofen+Betahistine            1 164 10
Folic acid+Baclofen                          1 26  2 
Piriton+Baclofen                             1 30  5 
Fentanyl/Co-beneldopa+Baclofen+Betahistine   1 90  10
Folic acid+Baclofen                          1 26  33
Fentanyl/Co-beneldopa+Baclofen               1 35  50
Folic acid+Baclofen                          1 15  6 
Cefalexin+Baclofen                           1 11  1 
Fentanyl/Co-beneldopa+Baclofen               2 35  14
Allopurinol+Baclofen+Betahistine             2 300 25
Folic acid+Baclofen+Betahistine              2 27  30
Cefalexin+Baclofen                           2 110 17
Allopurinol+Baclofen+Betahistine             2 240 55
Cefalexin+Baclofen                           2 11  17
Folic acid+Baclofen                          2 26  33
Piriton+Baclofen                             3 77  9 
Folic acid+Baclofen+Betahistine              3 27  19
Allopurinol+Baclofen+Betahistine             3 105 16
Piriton+Baclofen                             3 210 8 
Cefalexin+Baclofen                           3 11  32
Piriton+Baclofen                             3 38  11
Cefalexin+Baclofen                           3 11  31
Cefalexin+Baclofen+Betahistine               3 200 20
Cefalexin+Baclofen                           3 11  10
Cefalexin+Baclofen                           4 11  4 
Fentanyl/Co-beneldopa+Baclofen               4 35  18
Diclofenac+Baclofen                          4 66  25
Diclofenac+Baclofen                          4 45  14
Fentanyl/Co-beneldopa+Baclofen               4 115 22
;
run;
&lt;BR /&gt;proc sgplot data=have;&lt;BR /&gt;    vbox treatment_duration &lt;BR /&gt;         /category= drug_type &lt;BR /&gt;         freq=num_of_patients&lt;BR /&gt;;&lt;BR /&gt;run;
&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 Jan 2023 18:17:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-mean-median-and-confidenceinterval-of-a-data-in-a/m-p/853316#M337263</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-01-11T18:17:19Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the mean median and confidenceinterval of a data (in a graph)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-mean-median-and-confidenceinterval-of-a-data-in-a/m-p/853401#M337308</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;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp; thanks for your reply, In your example you assigned the treatment_duration to vbox, drug_type to category and num_of_patients to freq. Is it also possible to assign the visits in the same plot or do I need a plot for each visit?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jan 2023 07:05:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-mean-median-and-confidenceinterval-of-a-data-in-a/m-p/853401#M337308</guid>
      <dc:creator>Anita_n</dc:creator>
      <dc:date>2023-01-12T07:05:44Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the mean median and confidenceinterval of a data (in a graph)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-mean-median-and-confidenceinterval-of-a-data-in-a/m-p/853420#M337312</link>
      <description>&lt;P&gt;It makes no sense to have VISITS on the same plot as the others. The vertical scales would not match, distorting the plot. Don't do this.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jan 2023 11:31:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-mean-median-and-confidenceinterval-of-a-data-in-a/m-p/853420#M337312</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-01-12T11:31:32Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the mean median and confidenceinterval of a data (in a graph)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-mean-median-and-confidenceinterval-of-a-data-in-a/m-p/853423#M337315</link>
      <description>&lt;P&gt;I suggest a few things:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Use PROC MEANS to compute the statistics you want&lt;/LI&gt;
&lt;LI&gt;Put the drug types on the Y axis, since the labels are so long.&lt;/LI&gt;
&lt;LI&gt;Use the SCATTER statement with the XERRORLOWER and XERRORUPPER options to display the mean and CL&lt;/LI&gt;
&lt;LI&gt;Use a second SCATTER statement to display the median&lt;/LI&gt;
&lt;/OL&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;                                          
infile datalines;                                   
input Drug_type $44. visit    treatment_duration  num_of_patients;
datalines; 
Cefalexin+Baclofen+Betahistine               1 120 15
Calcipotriol+Baclofen+Betahistine            1 164 10
Folic acid+Baclofen                          1 26  2 
Piriton+Baclofen                             1 30  5 
Fentanyl/Co-beneldopa+Baclofen+Betahistine   1 90  10
Folic acid+Baclofen                          1 26  33
Fentanyl/Co-beneldopa+Baclofen               1 35  50
Folic acid+Baclofen                          1 15  6 
Cefalexin+Baclofen                           1 11  1 
Fentanyl/Co-beneldopa+Baclofen               2 35  14
Allopurinol+Baclofen+Betahistine             2 300 25
Folic acid+Baclofen+Betahistine              2 27  30
Cefalexin+Baclofen                           2 110 17
Allopurinol+Baclofen+Betahistine             2 240 55
Cefalexin+Baclofen                           2 11  17
Folic acid+Baclofen                          2 26  33
Piriton+Baclofen                             3 77  9 
Folic acid+Baclofen+Betahistine              3 27  19
Allopurinol+Baclofen+Betahistine             3 105 16
Piriton+Baclofen                             3 210 8 
Cefalexin+Baclofen                           3 11  32
Piriton+Baclofen                             3 38  11
Cefalexin+Baclofen                           3 11  31
Cefalexin+Baclofen+Betahistine               3 200 20
Cefalexin+Baclofen                           3 11  10
Cefalexin+Baclofen                           4 11  4 
Fentanyl/Co-beneldopa+Baclofen               4 35  18
Diclofenac+Baclofen                          4 66  25
Diclofenac+Baclofen                          4 45  14
Fentanyl/Co-beneldopa+Baclofen               4 115 22
;

/* https://blogs.sas.com/content/iml/2019/10/09/statistic-error-bars-mean.html */
proc means data=have noprint;
   class drug_type;
   freq num_of_patients;
   var treatment_duration;
   output out=MeanOut Mean=Mean Median=Median lclm=LCLM uclm=UCLM;
run;

title "Mean and Median Treatment Length";
title2 "95% Confidence Interval for Mean";
proc sgplot data=MeanOut;
scatter y=drug_type x=Mean / xerrorlower=lclm xerrorupper=uclm
        legendlabel="Mean";
scatter y=drug_type x=Median / legendlabel="Median" markerattrs=(Symbol=Diamond);
xaxis label="Treatment Length";
yaxis display=(nolabel);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Jan 2023 11:34:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-mean-median-and-confidenceinterval-of-a-data-in-a/m-p/853423#M337315</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2023-01-12T11:34:21Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the mean median and confidenceinterval of a data (in a graph)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-mean-median-and-confidenceinterval-of-a-data-in-a/m-p/853483#M337341</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/168930"&gt;@Anita_n&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp; thanks for your reply, In your example you assigned the treatment_duration to vbox, drug_type to category and num_of_patients to freq. Is it also possible to assign the visits in the same plot or do I need a plot for each visit?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Whether it is worth doing depends on what you mean by "assign the visits". Do you mean a separate overlay plot of Vbox=treatment_duration and Category=Visit? Or use Group=Visit? Your example data isn't going to have much range of values inside visit and treatment and just visit across drugs doesn't seem to make much sense, but I'm not a drug expert in any sense.&lt;/P&gt;
&lt;P&gt;Another option might be to use SGPANEL with Visit as the Panelby variable. That would make a separate graph for each level of visit.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jan 2023 16:09:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-mean-median-and-confidenceinterval-of-a-data-in-a/m-p/853483#M337341</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-01-12T16:09:24Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the mean median and confidenceinterval of a data (in a graph)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-mean-median-and-confidenceinterval-of-a-data-in-a/m-p/853516#M337364</link>
      <description>&lt;P&gt;Thankyou, I used ods gridded layout to arrange each plot per visit. It's okay now&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jan 2023 17:36:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-mean-median-and-confidenceinterval-of-a-data-in-a/m-p/853516#M337364</guid>
      <dc:creator>Anita_n</dc:creator>
      <dc:date>2023-01-12T17:36:02Z</dc:date>
    </item>
  </channel>
</rss>

