<?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 how do I use proc means for multiple data sets with the class statement? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/how-do-I-use-proc-means-for-multiple-data-sets-with-the-class/m-p/547449#M8381</link>
    <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to SAS and I am a bit confused on how to use the class statement for two datasets. I thought I would not need to merge them with a class but I am not sure. Please see the code I have written below which is missing the second dataset because I am not sure where it fits in:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* My question
Using the SAS datasets demogdemo and visitdemo and PROC MEANS with the CLASS statement, compute the mean, median, 25th percentile, 
75th percentile, and the number of non-missing values for the variables CD4, Weight, and Age for each value of civil status 
including missing.  Report the statistics to three decimal places.  In the same PROC MEANS, create a summary dataset with the 
OUTPUT statement containing the median and mean of CD4, Weight, and Age.  Using _TYPE_, print only the overall (i.e. all civil 
status categories combined) mean and median from this summary dataset. */

/*My starter solution*/

title "Using a CLASS Statement with PROC MEANS";
proc means data=lb.visitdemo n mean median Q1 Q3 maxdec=3; *where do I put demogdemo? Do I need to merge it in with visit demo in a different datastep first?;
	class civilstatus;
	var CD4 Weight Age ;
	output out = newdataset; 
		median = md_CD4 md_Weight md_Age; 
		mean = m_CD4 m_Weight m_Age;
run;
proc &lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 30 Mar 2019 22:27:06 GMT</pubDate>
    <dc:creator>cheenaChuks</dc:creator>
    <dc:date>2019-03-30T22:27:06Z</dc:date>
    <item>
      <title>how do I use proc means for multiple data sets with the class statement?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-do-I-use-proc-means-for-multiple-data-sets-with-the-class/m-p/547449#M8381</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to SAS and I am a bit confused on how to use the class statement for two datasets. I thought I would not need to merge them with a class but I am not sure. Please see the code I have written below which is missing the second dataset because I am not sure where it fits in:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* My question
Using the SAS datasets demogdemo and visitdemo and PROC MEANS with the CLASS statement, compute the mean, median, 25th percentile, 
75th percentile, and the number of non-missing values for the variables CD4, Weight, and Age for each value of civil status 
including missing.  Report the statistics to three decimal places.  In the same PROC MEANS, create a summary dataset with the 
OUTPUT statement containing the median and mean of CD4, Weight, and Age.  Using _TYPE_, print only the overall (i.e. all civil 
status categories combined) mean and median from this summary dataset. */

/*My starter solution*/

title "Using a CLASS Statement with PROC MEANS";
proc means data=lb.visitdemo n mean median Q1 Q3 maxdec=3; *where do I put demogdemo? Do I need to merge it in with visit demo in a different datastep first?;
	class civilstatus;
	var CD4 Weight Age ;
	output out = newdataset; 
		median = md_CD4 md_Weight md_Age; 
		mean = m_CD4 m_Weight m_Age;
run;
proc &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 30 Mar 2019 22:27:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-do-I-use-proc-means-for-multiple-data-sets-with-the-class/m-p/547449#M8381</guid>
      <dc:creator>cheenaChuks</dc:creator>
      <dc:date>2019-03-30T22:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: how do I use proc means for multiple data sets with the class statement?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-do-I-use-proc-means-for-multiple-data-sets-with-the-class/m-p/547453#M8382</link>
      <description>&lt;P&gt;You have left out a lot of key information but I think the answer is you cannot use one proc step to operate on multiple input datasets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data for_analysis;
  length insdname $41 ds $32 ;
  set demog1 demog2 indsname=indsname;
  ds=scan(indsname,-1,'.');
run;
proc means data=for_analysis;
  class ds;
  ....
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 30 Mar 2019 22:59:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-do-I-use-proc-means-for-multiple-data-sets-with-the-class/m-p/547453#M8382</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-03-30T22:59:37Z</dc:date>
    </item>
    <item>
      <title>Re: how do I use proc means for multiple data sets with the class statement?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-do-I-use-proc-means-for-multiple-data-sets-with-the-class/m-p/547454#M8383</link>
      <description>&lt;P&gt;What information is missing out please? I have modified my code but I had to do a merge by" first. I don't think this is what my professor wanted but I am not sure there are other ways. Is there a way to use the proc means without the first data steo&amp;nbsp;I included? Could you take a look at the edited code?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data myMerger (keep = patient_id CD4 Weight Age civilstatus); /* Keeping required variables for future proc means*/
merge lb.visitdemo lb.demogdemo;
by patient_id;
title "Using a CLASS Statement with PROC MEANS";
proc means data=myMerger n mean median Q1 Q3 maxdec=3; 
	class civilstatus;
	var CD4 Weight Age ;
	output out = newdataset
		median = md_CD4 md_Weight md_Age
		mean = m_CD4 m_Weight m_Age;
run;
proc print data = newdataset;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;?&lt;/P&gt;</description>
      <pubDate>Sat, 30 Mar 2019 23:03:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-do-I-use-proc-means-for-multiple-data-sets-with-the-class/m-p/547454#M8383</guid>
      <dc:creator>cheenaChuks</dc:creator>
      <dc:date>2019-03-30T23:03:03Z</dc:date>
    </item>
    <item>
      <title>Re: how do I use proc means for multiple data sets with the class statement?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-do-I-use-proc-means-for-multiple-data-sets-with-the-class/m-p/547455#M8384</link>
      <description>&lt;P&gt;We have no idea if that is right since we know nothing about the two datasets.&amp;nbsp; Which variables are coming from which dataset?&lt;/P&gt;
&lt;P&gt;Do they both actually have the variable PATIENT_ID?&amp;nbsp; Are they sorted?&lt;/P&gt;
&lt;P&gt;Do they both have one observation per PATIENT_ID?&amp;nbsp; Or does only one have multiple observations per PATIENT_ID? Or do both ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Mar 2019 23:08:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-do-I-use-proc-means-for-multiple-data-sets-with-the-class/m-p/547455#M8384</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-03-30T23:08:28Z</dc:date>
    </item>
    <item>
      <title>Re: how do I use proc means for multiple data sets with the class statement?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-do-I-use-proc-means-for-multiple-data-sets-with-the-class/m-p/547459#M8386</link>
      <description>&lt;P&gt;Which variables are coming from which dataset?&lt;STRONG&gt; CD4 is from &lt;/STRONG&gt;demog&lt;STRONG&gt;&amp;nbsp;data while &lt;/STRONG&gt;apptdate&lt;STRONG&gt; and all the other variables are from visit data. Patient id is in both of them.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Do they both actually have the variable PATIENT_ID?&amp;nbsp; &lt;STRONG&gt;yes.&lt;/STRONG&gt;&amp;nbsp; Are they sorted? &lt;STRONG&gt;yes&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Do they both have one observation per PATIENT_ID? yes Or does only one have multiple observations per PATIENT_ID? &lt;STRONG&gt;no&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 31 Mar 2019 00:33:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-do-I-use-proc-means-for-multiple-data-sets-with-the-class/m-p/547459#M8386</guid>
      <dc:creator>cheenaChuks</dc:creator>
      <dc:date>2019-03-31T00:33:46Z</dc:date>
    </item>
    <item>
      <title>Re: how do I use proc means for multiple data sets with the class statement?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-do-I-use-proc-means-for-multiple-data-sets-with-the-class/m-p/547460#M8387</link>
      <description>&lt;P&gt;If you have variables in both data sets that you want to use at the same time within PROC MEANS you have to merge the files.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/263788"&gt;@cheenaChuks&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Which variables are coming from which dataset?&lt;STRONG&gt; CD4 is from &lt;/STRONG&gt;demog&lt;STRONG&gt;&amp;nbsp;data while &lt;/STRONG&gt;apptdate&lt;STRONG&gt; and all the other variables are from visit data. Patient id is in both of them.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Do they both actually have the variable PATIENT_ID?&amp;nbsp; &lt;STRONG&gt;yes.&lt;/STRONG&gt;&amp;nbsp; Are they sorted? &lt;STRONG&gt;yes&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Do they both have one observation per PATIENT_ID? yes Or does only one have multiple observations per PATIENT_ID? &lt;STRONG&gt;no&lt;/STRONG&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 31 Mar 2019 01:53:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-do-I-use-proc-means-for-multiple-data-sets-with-the-class/m-p/547460#M8387</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-03-31T01:53:51Z</dc:date>
    </item>
  </channel>
</rss>

