<?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: displaying proc means in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/displaying-proc-means/m-p/213840#M52724</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Some tips.&amp;nbsp; Firstly, follow some good programming practices, indent within groups, end statements with run; or quit;&amp;nbsp; Give some test data and required output.&amp;nbsp; Minimise the question, the code is too long and without anything to run it on, am not going to spend the time trying to figure out what its doing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Secondly, not sure why you are breaking your dataset up and running means on each part, use a by statement or a class statement (they have slightly different resulting rows) in the means.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thirdly, for missings there are a few ways to do it.&amp;nbsp; Me personally I create a template dataset which has all the required outputs rows, this I then set with the means result to ensure all categories are present&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 13 May 2015 08:49:05 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2015-05-13T08:49:05Z</dc:date>
    <item>
      <title>displaying proc means</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/displaying-proc-means/m-p/213839#M52723</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello community, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following code does not include personal information of individuals. In the following code, I am trying to do simple descriptive statistics using proc means of 6 continuous variables with a previously established outcome variable, "bothstatus".&lt;/P&gt;&lt;P&gt;Bothstatus has 4 outcome levels, these reflect HIV and HSV status of npnidentifiable persons: &lt;/P&gt;&lt;P&gt;0= "HIV-, HSV-"&lt;/P&gt;&lt;P&gt;1= "HIV-,HSV+"&lt;/P&gt;&lt;P&gt;2="HIV+, HSV-"&lt;/P&gt;&lt;P&gt;3= "HIV+, HSV+"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With the following code, I'm trying to first display descriptive statistics per level of this outcome variable, "bothstatus", this is displayed by each proc means procedure for all 6 continuous variables. The proc means is arranged in such a way, so that the mean, standard deviation and number of observations can be displayed in the output for each variable. However, I would like some assistance as to how to display missing for each variable, hopefully in the same table. I have tried coding number missing as "nmiss" in the proc means line, I have also tried coding it similar to std, mean, and number of observations, but it does not display any missing. Any assistance with this part will be great. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The next section of code, attempts to merge the 4 output datasets created in the 4 proc means statements. This merge, with its respective proc print procedure is done for all 6 continuous variables. In this section, I was needing help as to how to display the different variables shown in proc print with a different output label... such as &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;the variable n0age can display: "number of observations: HIV-, HSV-", another example, n1age can display "HIV-,HSV+"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I believe this code can also be less cumbersome if I change the coding of the outcome variable, bothstatus, can be recoded to a character variable. However I do not know well how to define values with labels, the code is as follows: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data NewVar2;&lt;/P&gt;&lt;P&gt; set psw.NewVar1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data hivhsvneg ;&lt;/P&gt;&lt;P&gt; set NewVar2 ;&lt;/P&gt;&lt;P&gt; if bothstatus=0 ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data hsvpos ;&lt;/P&gt;&lt;P&gt; set NewVar2&amp;nbsp; ;&lt;/P&gt;&lt;P&gt; if bothstatus=1 ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; data hivpos ;&lt;/P&gt;&lt;P&gt; set NewVar2&amp;nbsp; ;&lt;/P&gt;&lt;P&gt; if bothstatus=2 ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; data hivhsvpos ;&lt;/P&gt;&lt;P&gt; set NewVar2&amp;nbsp; ;&lt;/P&gt;&lt;P&gt; if bothstatus=3 ;&lt;/P&gt;&lt;P&gt; *Means procedure for each level of the outcome variable;&lt;/P&gt;&lt;P&gt;* new method to develop proc means for each level;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; title 'Descriptive statistics: HIV-, HSV-';&lt;/P&gt;&lt;P&gt; proc means data=hivhsvneg;&lt;/P&gt;&lt;P&gt;var age yrssch sex_1st fstepa fcaspa flifpa2;&lt;/P&gt;&lt;P&gt;output out=hivhsvneg&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; n=n0age n0yrssch n0sex_1st n0fstepa n0fcaspa n0flifpa2&lt;/P&gt;&lt;P&gt;mean=mean0age mean0yrssch mean0sex_1st mean0fstepa mean0fcaspa mean0flifpa2&lt;/P&gt;&lt;P&gt;std= std0age std0yrssch std0sex_1st std0fstepa std0fcaspa std0flifpa2;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;*nmiss=nmiss0age nmiss0yrssch nmiss0sex_1st nmiss0fstepa nmiss0fcaspa nmiss0flifpa2;&lt;/P&gt;&lt;P&gt;title 'Descriptive statistics: HIV-, HSV+';&lt;/P&gt;&lt;P&gt;proc means data=hsvpos;&lt;/P&gt;&lt;P&gt;var age yrssch sex_1st fstepa fcaspa flifpa2;&lt;/P&gt;&lt;P&gt;output out=hsvpos&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; n=n1age n1yrssch n1sex_1st n1fstepa n1fcaspa n1flifpa2&lt;/P&gt;&lt;P&gt;mean=mean1age mean1yrssch mean1sex_1st mean1fstepa mean1fcaspa mean1flifpa2&lt;/P&gt;&lt;P&gt;std= std1age std1yrssch std1sex_1st std1fstepa std1fcaspa std1flifpa2;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;title 'Descriptive statistics: HIV+, HSV-';&lt;/P&gt;&lt;P&gt;proc means data=hivpos;&lt;/P&gt;&lt;P&gt;var age yrssch sex_1st fstepa fcaspa flifpa2;&lt;/P&gt;&lt;P&gt;output out=hivpos&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; n=n2age n2yrssch n2sex_1st n2fstepa n2fcaspa n2flifpa2&lt;/P&gt;&lt;P&gt;mean=mean2age mean2yrssch mean2sex_1st mean2fstepa mean2fcaspa mean2flifpa2&lt;/P&gt;&lt;P&gt;std= std2age std2yrssch std2sex_1st std2fstepa std2fcaspa std2flifpa2;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;title 'Descriptive statistics: HIV+, HSV+';&lt;/P&gt;&lt;P&gt;proc means data=hivhsvpos;&lt;/P&gt;&lt;P&gt;var age yrssch sex_1st fstepa fcaspa flifpa2;&lt;/P&gt;&lt;P&gt;output out=hivhsvpos n=n3age n3yrssch n3sex_1st n3fstepa n3fcaspa n3flifpa2&lt;/P&gt;&lt;P&gt;mean=mean3age mean3yrssch mean3sex_1st mean3fstepa mean3fcaspa mean3flifpa2&lt;/P&gt;&lt;P&gt;std= std3age std3yrssch std3sex_1st std3fstepa std3fcaspa std3flifpa2;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;ods pdf close;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;** Merging of datasets output for each continuous variable;&lt;/P&gt;&lt;P&gt;* age merge output;&lt;/P&gt;&lt;P&gt;data age ;&lt;/P&gt;&lt;P&gt; merge hivhsvneg hsvpos hivpos hivhsvpos ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; proc print data=age ;&lt;/P&gt;&lt;P&gt; var n0age n1age n2age n3age mean0age mean1age mean2age mean3age std0age std1age std2age std3age;&lt;/P&gt;&lt;P&gt; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*yrssch merge output;&lt;/P&gt;&lt;P&gt;data yrssch ;&lt;/P&gt;&lt;P&gt; merge hivhsvneg hsvpos hivpos hivhsvpos ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print data=yrssch ;&lt;/P&gt;&lt;P&gt; var n0yrssch n1yrssch n2yrssch n3yrssch mean0yrssch mean1yrssch mean2yrssch mean3yrssch std0yrssch std1yrssch std2yrssch std3yrssch ;&lt;/P&gt;&lt;P&gt;run ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*sex_1st merge output;&lt;/P&gt;&lt;P&gt;data firstsex ;&lt;/P&gt;&lt;P&gt; merge hivhsvneg hsvpos hivpos hivhsvpos;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print data=firstsex ;&lt;/P&gt;&lt;P&gt; var n0sex_1st n1sex_1st n2sex_1st n3sex_1st mean0sex_1st mean1sex_1st mean2sex_1st mean3sex_1st std0sex_1st std1sex_1st std2sex_1st std3sex_1st ;&lt;/P&gt;&lt;P&gt;run ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*fstepa merge output;&lt;/P&gt;&lt;P&gt;data fstepa ;&lt;/P&gt;&lt;P&gt; merge hivhsvneg hsvpos hivpos hivhsvpos;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print data=fstepa ;&lt;/P&gt;&lt;P&gt; var n0fstepa n1fstepa n2fstepa fstepa mean0fstepa mean1fstepa mean2fstepa mean3fstepa std0fstepa std1fstepa std2fstepa std3fstepa;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*fcaspa merge output;&lt;/P&gt;&lt;P&gt;data fcaspa ;&lt;/P&gt;&lt;P&gt; merge hivhsvneg hsvpos hivpos hivhsvpos;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print data=fcaspa ;&lt;/P&gt;&lt;P&gt; var n0fcaspa n1fcaspa n2fcaspa n3fcaspa mean0fcaspa mean1fcaspa mean2fcaspa mean3fcaspa std0fcaspa std1fcaspa std2fcaspa std3fcaspa ;&lt;/P&gt;&lt;P&gt;run ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*flifpa2 merge output;&lt;/P&gt;&lt;P&gt;data flifpa2 ;&lt;/P&gt;&lt;P&gt; merge hivhsvneg hsvpos hivpos hivhsvpos;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print data=flifpa2 ;&lt;/P&gt;&lt;P&gt; var n0flifpa2 n1flifpa2 n2flifpa2 n3flifpa2 mean0flifpa2 mean1flifpa2 mean2flifpa2 mean3flifpa2 std0flifpa2 std1flifpa2 std2flifpa2 std3flifpa2 ;&lt;/P&gt;&lt;P&gt;run ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you so much!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 May 2015 07:28:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/displaying-proc-means/m-p/213839#M52723</guid>
      <dc:creator>Macyhe22</dc:creator>
      <dc:date>2015-05-13T07:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: displaying proc means</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/displaying-proc-means/m-p/213840#M52724</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Some tips.&amp;nbsp; Firstly, follow some good programming practices, indent within groups, end statements with run; or quit;&amp;nbsp; Give some test data and required output.&amp;nbsp; Minimise the question, the code is too long and without anything to run it on, am not going to spend the time trying to figure out what its doing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Secondly, not sure why you are breaking your dataset up and running means on each part, use a by statement or a class statement (they have slightly different resulting rows) in the means.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thirdly, for missings there are a few ways to do it.&amp;nbsp; Me personally I create a template dataset which has all the required outputs rows, this I then set with the means result to ensure all categories are present&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 May 2015 08:49:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/displaying-proc-means/m-p/213840#M52724</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-05-13T08:49:05Z</dc:date>
    </item>
    <item>
      <title>Re: displaying proc means</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/displaying-proc-means/m-p/213841#M52725</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;See if this is helpful:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc format;&lt;/P&gt;&lt;P&gt;value bothstatus&lt;/P&gt;&lt;P&gt;0= "HIV-, HSV-"&lt;/P&gt;&lt;P&gt;1= "HIV-,HSV+"&lt;/P&gt;&lt;P&gt;2="HIV+, HSV-"&lt;/P&gt;&lt;P&gt;3= "HIV+, HSV+"&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc tabulate data=psw.NewVar1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class bothstatus / preloadfmt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; format bothstatus bothstatus.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var&amp;nbsp; age yrssch sex_1st fstepa fcaspa flifpa2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; table bothstatus * ( age yrssch sex_1st fstepa fcaspa flifpa2),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; n mean std&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; / printmiss ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 May 2015 15:12:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/displaying-proc-means/m-p/213841#M52725</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-05-13T15:12:59Z</dc:date>
    </item>
  </channel>
</rss>

