<?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: Counting variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/510239#M137323</link>
    <description>&lt;P&gt;Please try the below code to derive the sum per year and if you could provide further details on the calculation with example data then we could improvise the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID _1995 _1996;
groupx=1;
cards;
1   1   . 
2   .   1
3   1   .
;


proc sql;
create table diction as select name from dictionary.columns where libname='WORK' and memname='HAVE' and name not in ('ID' 'GROUPX');
select cat('sum(',strip(name),') as ',strip(name)) into: vars separated by ',' from dictionary.columns where libname='WORK' and memname='HAVE' and upcase(name) not in ('ID' 'GROUPX');
create table want as select &amp;amp;vars from have group by groupx;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp; &lt;/P&gt;</description>
    <pubDate>Sun, 04 Nov 2018 11:23:01 GMT</pubDate>
    <dc:creator>Jagadishkatam</dc:creator>
    <dc:date>2018-11-04T11:23:01Z</dc:date>
    <item>
      <title>Counting variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/510221#M137313</link>
      <description>&lt;P&gt;Hi there! I am trying to calculate incidence rates across a 20+ year period. A portion of my dataset looks like this, where 1 is a new diagnosis of the disease in that year. I need to sum all of the incident cases of the disease in each year, and then divide each sum by the n of the total population in each year (derived from a different dataset and then merged with this one), &amp;amp; *100000. I’m struggling with how to do these analyses that is not so tedious where I have to do the calculations singularly year by year. For example, can I do a do loop where the total n is different in each of the years?&lt;BR /&gt;&lt;BR /&gt;ID 1995 1996 ... 2016&lt;BR /&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;BR /&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; . &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp;&lt;BR /&gt;:&lt;BR /&gt;:&lt;BR /&gt;n &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; 1&lt;/P&gt;</description>
      <pubDate>Sun, 04 Nov 2018 04:38:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/510221#M137313</guid>
      <dc:creator>hellohello1</dc:creator>
      <dc:date>2018-11-04T04:38:42Z</dc:date>
    </item>
    <item>
      <title>Re: Counting variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/510224#M137315</link>
      <description>&lt;P&gt;Every data management operation&amp;nbsp;will become simpler in SAS if you change your data structure to&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID Year Diag&lt;/P&gt;
&lt;P&gt;1 1995&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;1 1996&amp;nbsp;&amp;nbsp; 0&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where Diag is 0 or 1.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 04 Nov 2018 05:02:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/510224#M137315</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-11-04T05:02:59Z</dc:date>
    </item>
    <item>
      <title>Re: Counting variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/510227#M137317</link>
      <description>&lt;P&gt;Your data structure is not clear enough to me:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; -&amp;nbsp; what does ID represent?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; -&amp;nbsp; what does&amp;nbsp; .&amp;nbsp; (a dot) represent - missing value or any other value differ from 1 ? can a value be 2 or 3 ... ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please post a real sample of your data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 04 Nov 2018 07:05:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/510227#M137317</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2018-11-04T07:05:20Z</dc:date>
    </item>
    <item>
      <title>Re: Counting variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/510239#M137323</link>
      <description>&lt;P&gt;Please try the below code to derive the sum per year and if you could provide further details on the calculation with example data then we could improvise the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID _1995 _1996;
groupx=1;
cards;
1   1   . 
2   .   1
3   1   .
;


proc sql;
create table diction as select name from dictionary.columns where libname='WORK' and memname='HAVE' and name not in ('ID' 'GROUPX');
select cat('sum(',strip(name),') as ',strip(name)) into: vars separated by ',' from dictionary.columns where libname='WORK' and memname='HAVE' and upcase(name) not in ('ID' 'GROUPX');
create table want as select &amp;amp;vars from have group by groupx;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp; &lt;/P&gt;</description>
      <pubDate>Sun, 04 Nov 2018 11:23:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/510239#M137323</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2018-11-04T11:23:01Z</dc:date>
    </item>
  </channel>
</rss>

