<?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: Shortcut for variable names in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Shortcut-for-variable-names/m-p/653370#M196258</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/290100"&gt;@zishaq&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;you can use a %do Loop in a macro program in order to be able tu replace the number by a macro variable as follows:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test ();
...
%do i=1 %to 6;
pay_0&amp;amp;i.= round(coalesce(gross_0&amp;amp;i.,0) + coalesce(pension_0&amp;amp;i.,0) + coalesce(nic_0&amp;amp;i.,0) , 0.01) ;
%end;
...
%mend;


%test()&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 04 Jun 2020 17:04:11 GMT</pubDate>
    <dc:creator>ed_sas_member</dc:creator>
    <dc:date>2020-06-04T17:04:11Z</dc:date>
    <item>
      <title>Shortcut for variable names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Shortcut-for-variable-names/m-p/653359#M196249</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm looking for a shorthand way to write the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;pay_01= round(coalesce(gross_01,0) + coalesce(pension_01,0) + coalesce(nic_01,0) , 0.01) ;&lt;BR /&gt;pay_02= round(coalesce(gross_02,0) + coalesce(pension_02,0) + coalesce(&lt;FONT&gt;nic&lt;/FONT&gt;_02,0) , 0.01) ;&lt;BR /&gt;pay_03= round(coalesce(&lt;FONT&gt;gross&lt;/FONT&gt;_03,0) + coalesce(pension_03,0) + coalesce(&lt;FONT&gt;nic&lt;/FONT&gt;_03,0) , 0.01) ;&lt;BR /&gt;pay_04= round(coalesce(&lt;FONT&gt;gross&lt;/FONT&gt;_04,0) + coalesce(pension_04,0) + coalesce(&lt;FONT&gt;nic&lt;/FONT&gt;_04,0) , 0.01) ;&lt;BR /&gt;pay_05= round(coalesce(&lt;FONT&gt;gross&lt;/FONT&gt;_05,0) + coalesce(pension_05,0) + coalesce(&lt;FONT&gt;nic&lt;/FONT&gt;_05,0) , 0.01) ;&lt;BR /&gt;pay_06= round(coalesce(&lt;FONT&gt;gross&lt;/FONT&gt;_06,0) + coalesce(pension_06,0) + coalesce(&lt;FONT&gt;nic&lt;/FONT&gt;_06,0) , 0.01) ;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can this be shortened to one line of code instead of having to compute for each of the 6 months?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 16:53:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Shortcut-for-variable-names/m-p/653359#M196249</guid>
      <dc:creator>zishaq</dc:creator>
      <dc:date>2020-06-04T16:53:17Z</dc:date>
    </item>
    <item>
      <title>Re: Shortcut for variable names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Shortcut-for-variable-names/m-p/653365#M196253</link>
      <description>&lt;P&gt;You are looking for a macro then.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%macro repeat (max=) ;
   %do i = 1 %to &amp;amp;max ;
      pay_0&amp;amp;i= round(coalesce(gross_0&amp;amp;i,0) + coalesce(pension_0&amp;amp;i,0) + coalesce(nic_0&amp;amp;i,0) , 0.01) ;
   %end ;
%mend  repeat ;
%repeat (max=6) ;
&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Jun 2020 17:01:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Shortcut-for-variable-names/m-p/653365#M196253</guid>
      <dc:creator>biopharma</dc:creator>
      <dc:date>2020-06-04T17:01:10Z</dc:date>
    </item>
    <item>
      <title>Re: Shortcut for variable names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Shortcut-for-variable-names/m-p/653366#M196254</link>
      <description>&lt;P&gt;did you try using the sum function&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 17:01:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Shortcut-for-variable-names/m-p/653366#M196254</guid>
      <dc:creator>smantha</dc:creator>
      <dc:date>2020-06-04T17:01:54Z</dc:date>
    </item>
    <item>
      <title>Re: Shortcut for variable names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Shortcut-for-variable-names/m-p/653368#M196256</link>
      <description>&lt;PRE&gt;%macro repeat (max=) ;
   %do i = 1 %to &amp;amp;max ;
      pay_0&amp;amp;i= round(sum(gross_0&amp;amp;i,pension_0&amp;amp;i, nic_0&amp;amp;i,0) , 0.01) ;
   %end ;
%mend  repeat ;
%repeat (max=6) ;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Jun 2020 17:03:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Shortcut-for-variable-names/m-p/653368#M196256</guid>
      <dc:creator>smantha</dc:creator>
      <dc:date>2020-06-04T17:03:23Z</dc:date>
    </item>
    <item>
      <title>Re: Shortcut for variable names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Shortcut-for-variable-names/m-p/653370#M196258</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/290100"&gt;@zishaq&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;you can use a %do Loop in a macro program in order to be able tu replace the number by a macro variable as follows:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test ();
...
%do i=1 %to 6;
pay_0&amp;amp;i.= round(coalesce(gross_0&amp;amp;i.,0) + coalesce(pension_0&amp;amp;i.,0) + coalesce(nic_0&amp;amp;i.,0) , 0.01) ;
%end;
...
%mend;


%test()&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Jun 2020 17:04:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Shortcut-for-variable-names/m-p/653370#M196258</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-06-04T17:04:11Z</dc:date>
    </item>
    <item>
      <title>Re: Shortcut for variable names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Shortcut-for-variable-names/m-p/653373#M196260</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array pay {*} pay_01-pay_06;
array gross {*} gross_01-gross_06;
array pension {*} pension_01-pension_06;
array nic {*} nic_01-nic_06;
do i = 1 to 6;
  pay{i} = round(sum(gross{I}, pension{I}, nic{I}),.01);
end;
drop i;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It would, of course, be much easier to use an untransposed dataset.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 17:10:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Shortcut-for-variable-names/m-p/653373#M196260</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-04T17:10:21Z</dc:date>
    </item>
    <item>
      <title>Re: Shortcut for variable names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Shortcut-for-variable-names/m-p/653375#M196262</link>
      <description>&lt;P&gt;Y'all suffer from macro-itis.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 17:12:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Shortcut-for-variable-names/m-p/653375#M196262</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-04T17:12:13Z</dc:date>
    </item>
    <item>
      <title>Re: Shortcut for variable names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Shortcut-for-variable-names/m-p/653376#M196263</link>
      <description>&lt;P&gt;Arrays are the correct approach here, though another option would be to transpose your data and operate on a long format. I suspect in general, the long format is better.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a tutorial on using Arrays in SAS&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/seminars/sas-arrays/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/seminars/sas-arrays/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a reference that illustrates how to refer to variables and datasets in a short cut list:&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Transposing data tutorials:&lt;BR /&gt;Wide to Long:&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-wide-to-long-using-proc-transpose/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-wide-to-long-using-proc-transpose/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/modules/reshaping-data-wide-to-long-using-a-data-step/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/modules/reshaping-data-wide-to-long-using-a-data-step/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 17:18:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Shortcut-for-variable-names/m-p/653376#M196263</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-06-04T17:18:04Z</dc:date>
    </item>
  </channel>
</rss>

