<?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: Need help with variable frequency by group and year in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-variable-frequency-by-group-and-year/m-p/661921#M197826</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=have nway;
class hospid year;
var var1 var2 var3 var4 var5 var6;
id charactervariablename;
output out=test mean=prop1-prop6;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 17 Jun 2020 21:18:26 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-06-17T21:18:26Z</dc:date>
    <item>
      <title>Need help with variable frequency by group and year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-variable-frequency-by-group-and-year/m-p/661887#M197812</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am currently working with a large surgical healthcare dataset with many individual observations (patients) that are clustered within hospitals. Right now, one observation corresponds to an individual &lt;STRONG&gt;&lt;EM&gt;patient&lt;/EM&gt;&lt;/STRONG&gt;,&amp;nbsp;(i.e. a surgical admission),&amp;nbsp;and I have variables identifying hospital ID, gender, year of surgery, etc. My goal is to create a new dataset where each observation represents an individual&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;hospital.&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;I would like the variables in that dataset to reflect&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;hospital&lt;/STRONG&gt;&lt;/EM&gt;&lt;EM&gt;&amp;nbsp;&lt;/EM&gt;proportions (means) of dichotomous variables for that year (e.g. proportion female patients per hospital per year). I tried using the following code to calculate means of all variables at once for each year, hoping to do this across 6 years and then merge all the datasets together. However, the output dataset only includes the mean for variable 1, not all 6 variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class="s1"&gt;&lt;STRONG&gt;means&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class="s2"&gt;data&lt;/SPAN&gt;=have&amp;nbsp;&lt;SPAN class="s2"&gt;mean&lt;/SPAN&gt; &lt;SPAN class="s2"&gt;nway&lt;/SPAN&gt;;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s2"&gt;class&lt;/SPAN&gt; hospid;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s2"&gt;var&lt;/SPAN&gt; var1 var2&amp;nbsp;var3 var4 var5 var6;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s2"&gt;output&lt;/SPAN&gt; &lt;SPAN class="s2"&gt;out&lt;/SPAN&gt;=test&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="s2"&gt;mean&lt;/SPAN&gt;=prop;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s2"&gt;where&lt;/SPAN&gt; year=&lt;SPAN class="s3"&gt;&lt;STRONG&gt;2011&lt;/STRONG&gt;&lt;/SPAN&gt;;&lt;/P&gt;&lt;P class="p2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN class="s4"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I cannot figure out how to create an output dataset that lists the mean (proportion) for all variables, classified by hospital ID. Does anyone have any suggestions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jun 2020 18:55:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-variable-frequency-by-group-and-year/m-p/661887#M197812</guid>
      <dc:creator>jgreenberg321</dc:creator>
      <dc:date>2020-06-17T18:55:15Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with variable frequency by group and year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-variable-frequency-by-group-and-year/m-p/661888#M197813</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=have nway;
class hospid year;
var var1 var2 var3 var4 var5 var6;
output out=test mean=prop1-prop6;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;No need to create data sets by year and then combine them — that's just extra and unnecessary work. The code above gives you one data set with all of your results.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jun 2020 18:58:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-variable-frequency-by-group-and-year/m-p/661888#M197813</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-06-17T18:58:58Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with variable frequency by group and year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-variable-frequency-by-group-and-year/m-p/661889#M197814</link>
      <description>&lt;P&gt;You could use&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=have mean nway;

class hospid year;

var var1 var2 var3 var4 var5 var6;

output out=test mean=/autoname;


run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Jun 2020 19:00:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-variable-frequency-by-group-and-year/m-p/661889#M197814</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-06-17T19:00:33Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with variable frequency by group and year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-variable-frequency-by-group-and-year/m-p/661892#M197815</link>
      <description>&lt;P&gt;Is this data set used for further analysis, such as input to a model or to show a report summary for people to read?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it is a report then perhaps either Proc Report or Tabulate would be in order.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jun 2020 19:11:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-variable-frequency-by-group-and-year/m-p/661892#M197815</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-17T19:11:55Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with variable frequency by group and year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-variable-frequency-by-group-and-year/m-p/661897#M197816</link>
      <description>&lt;P&gt;This looks like it should be perfect. Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do intend to perform additional models on this new dataset. Is there any reason that would necessitate that I use proc report or proc tabulate?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you all!&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jun 2020 19:26:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-variable-frequency-by-group-and-year/m-p/661897#M197816</guid>
      <dc:creator>jgreenberg321</dc:creator>
      <dc:date>2020-06-17T19:26:19Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with variable frequency by group and year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-variable-frequency-by-group-and-year/m-p/661919#M197825</link>
      <description>Quick follow-up question: I also have a character variable for state in the dataset. Is there an efficient way in the same data step to keep that variable in the output ("test") dataset? If not, I can always merge it back in as a separate step; that just seemed less efficient. Thank you again!</description>
      <pubDate>Wed, 17 Jun 2020 21:08:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-variable-frequency-by-group-and-year/m-p/661919#M197825</guid>
      <dc:creator>jgreenberg321</dc:creator>
      <dc:date>2020-06-17T21:08:18Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with variable frequency by group and year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-variable-frequency-by-group-and-year/m-p/661921#M197826</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=have nway;
class hospid year;
var var1 var2 var3 var4 var5 var6;
id charactervariablename;
output out=test mean=prop1-prop6;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Jun 2020 21:18:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-variable-frequency-by-group-and-year/m-p/661921#M197826</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-06-17T21:18:26Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with variable frequency by group and year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-variable-frequency-by-group-and-year/m-p/661923#M197828</link>
      <description>That’s perfect! Thank you!&lt;BR /&gt;</description>
      <pubDate>Wed, 17 Jun 2020 21:27:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-variable-frequency-by-group-and-year/m-p/661923#M197828</guid>
      <dc:creator>jgreenberg321</dc:creator>
      <dc:date>2020-06-17T21:27:11Z</dc:date>
    </item>
  </channel>
</rss>

