<?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: how to get a total for a number of medical codes in macro statement? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/how-to-get-a-total-for-a-number-of-medical-codes-in-macro/m-p/649582#M22262</link>
    <description>&lt;P&gt;This would all be much easier if you are working with data in a data set, which I speculate you are.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
    select distinct quote(code) into :hcpcs separated by ',' from yourdatasetname;
quit;
%let num_codes=&amp;amp;sqlobs;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 21 May 2020 14:34:22 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-05-21T14:34:22Z</dc:date>
    <item>
      <title>how to get a total for a number of medical codes in macro statement?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-get-a-total-for-a-number-of-medical-codes-in-macro/m-p/649580#M22261</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Its likely that I am wording my question in the subject completely wrong as I am new to SAS and don't understand all of the verbiage. However, I am trying to include a statement in my macros code that will generate a total for a number of medical codes. I will include an excerpt of the code that I have thus far.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let hcpcs=%str('36473', '36474', '36475', '36476', '36478', '36479',&lt;BR /&gt;'36482', '36483', '20912', '21210', '21235', '30400', '30410', '30420',&lt;BR /&gt;'30430', '30435', '30450', '30460', '30462', '30465', '15877', '20912',&lt;BR /&gt;'21210', '21235', '30400', '30410', '30420', '30430', '30435', '30450',&lt;BR /&gt;'30460', '30462', '30465', '30520', '36473', '36474', '36475', '36476',&lt;BR /&gt;'36478', '36479', '36482', '36483');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way that I can add another value to this string that will allow for calculations of the total of all of these codes?&lt;/P&gt;</description>
      <pubDate>Thu, 21 May 2020 14:34:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-get-a-total-for-a-number-of-medical-codes-in-macro/m-p/649580#M22261</guid>
      <dc:creator>SM8</dc:creator>
      <dc:date>2020-05-21T14:34:48Z</dc:date>
    </item>
    <item>
      <title>Re: how to get a total for a number of medical codes in macro statement?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-get-a-total-for-a-number-of-medical-codes-in-macro/m-p/649582#M22262</link>
      <description>&lt;P&gt;This would all be much easier if you are working with data in a data set, which I speculate you are.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
    select distinct quote(code) into :hcpcs separated by ',' from yourdatasetname;
quit;
%let num_codes=&amp;amp;sqlobs;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 May 2020 14:34:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-get-a-total-for-a-number-of-medical-codes-in-macro/m-p/649582#M22262</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-05-21T14:34:22Z</dc:date>
    </item>
    <item>
      <title>Re: how to get a total for a number of medical codes in macro statement?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-get-a-total-for-a-number-of-medical-codes-in-macro/m-p/649585#M22263</link>
      <description>&lt;P&gt;I am! Can you explain this a little further, please?&lt;/P&gt;</description>
      <pubDate>Thu, 21 May 2020 14:36:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-get-a-total-for-a-number-of-medical-codes-in-macro/m-p/649585#M22263</guid>
      <dc:creator>SM8</dc:creator>
      <dc:date>2020-05-21T14:36:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to get a total for a number of medical codes in macro statement?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-get-a-total-for-a-number-of-medical-codes-in-macro/m-p/649605#M22264</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/299741"&gt;@SM8&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let hcpcs=%bquote('36473', '36474', '36475', '36476', '36478', '36479',
'36482', '36483', '20912', '21210', '21235', '30400', '30410', '30420',
'30430', '30435', '30450', '30460', '30462', '30465', '15877', '20912',
'21210', '21235', '30400', '30410', '30420', '30430', '30435', '30450',
'30460', '30462', '30465', '30520', '36473', '36474', '36475', '36476',
'36478', '36479', '36482', '36483');

%put &amp;amp;=hcpcs;

%let total_codes=%sysfunc(countw(&amp;amp;hcpcs,%str(,)));

%put &amp;amp;=total_codes;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 May 2020 15:24:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-get-a-total-for-a-number-of-medical-codes-in-macro/m-p/649605#M22264</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-05-21T15:24:37Z</dc:date>
    </item>
    <item>
      <title>Re: how to get a total for a number of medical codes in macro statement?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-get-a-total-for-a-number-of-medical-codes-in-macro/m-p/649606#M22265</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/299741"&gt;@SM8&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let hcpcs=%bquote('36473', '36474', '36475', '36476', '36478', '36479',
'36482', '36483', '20912', '21210', '21235', '30400', '30410', '30420',
'30430', '30435', '30450', '30460', '30462', '30465', '15877', '20912',
'21210', '21235', '30400', '30410', '30420', '30430', '30435', '30450',
'30460', '30462', '30465', '30520', '36473', '36474', '36475', '36476',
'36478', '36479', '36482', '36483');

%put &amp;amp;=hcpcs;

%let total_codes=%sysfunc(countw(&amp;amp;hcpcs,%str(,)));

%put &amp;amp;=total_codes;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Although %str() and %bquote() in this example will do the same thing, there are other situations where %str() would be the logical correct choice, and I am not able to envision a situation where %bquote() is needed in this or similar examples. In fact, the creation of &amp;amp;HCPCS in this example doesn't need either %str() or %bquote().&lt;/P&gt;</description>
      <pubDate>Thu, 21 May 2020 15:31:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-get-a-total-for-a-number-of-medical-codes-in-macro/m-p/649606#M22265</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-05-21T15:31:11Z</dc:date>
    </item>
    <item>
      <title>Re: how to get a total for a number of medical codes in macro statement?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-get-a-total-for-a-number-of-medical-codes-in-macro/m-p/649607#M22266</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/299741"&gt;@SM8&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Can you explain this a little further, please?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you have a data set with the codes, then this PROC SQL searches the data set for all codes contained, and puts them into the macro variable HCPCS with quotes around the codes and separated by a comma.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;amp;SQLOBS is the number of (in this case) distinct codes found.&lt;/P&gt;</description>
      <pubDate>Thu, 21 May 2020 15:30:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-get-a-total-for-a-number-of-medical-codes-in-macro/m-p/649607#M22266</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-05-21T15:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: how to get a total for a number of medical codes in macro statement?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-get-a-total-for-a-number-of-medical-codes-in-macro/m-p/649608#M22267</link>
      <description>&lt;P&gt;&lt;EM&gt;"In fact, the creation of &amp;amp;HCPCS in this example doesn't need either %str() or %bquote() in this example." -&amp;nbsp;&lt;/EM&gt;Yes true for the reason there isn't any unbalanced quotes. So the tokenisation isn't impacted for word scanner to safely determine the literal tokens&lt;/P&gt;</description>
      <pubDate>Thu, 21 May 2020 15:34:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-get-a-total-for-a-number-of-medical-codes-in-macro/m-p/649608#M22267</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-05-21T15:34:19Z</dc:date>
    </item>
  </channel>
</rss>

