<?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 coding error: how to create a list of values by using sql into: properly in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/coding-error-how-to-create-a-list-of-values-by-using-sql-into/m-p/432536#M281794</link>
    <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a problem creating a&amp;nbsp;macro variable made up of values in different length needed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here I tried to store the list of&amp;nbsp; icd10 code corresponding to a certain value of another variable called ccs10Cat.&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(compress(icd10Code)) format $7., "CCS10_&amp;amp;ccsValue."
         into  :icd10list separated by ",", 
               :ccs10Var
	        from Ccs.Icd10ccsmapping
		       where compress(ccs10Cat) in ("&amp;amp;ccsValue.");
   quit;

   %put &amp;amp;icd10list;
   %put &amp;amp;ccs10Var;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Ideally, i could save the icd10 codes like&amp;nbsp;&lt;SPAN&gt;'I8000',&amp;nbsp;'I8001', .....'&lt;FONT color="#FF6600"&gt;I80201&lt;/FONT&gt;', '&lt;FONT color="#FF6600"&gt;I80202&lt;/FONT&gt;'........ 'Z86718', 'Z8672' into the list for a value of the corresponding ccs equal to 118.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;In general, an icd10 code could be up to 7 characters in length. But here&amp;nbsp;the maximum that i saved is 5. As you can see the value&amp;nbsp;like "I8012" was supposed to be&amp;nbsp;'&lt;FONT color="#FF6600"&gt;I80201&lt;/FONT&gt;'.&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;SYMBOLGEN: Macro variable ICD10LIST resolves to
"I8000","I8001","I8002","I8003","I8010","I8011","I8012","I8013","I8020","I8021","I8022","I8023","I8029","I803","I80
8","I809","I81","I820","I821","I8221","I8222","I8229","I823","I8240","I8241","I8242","I8243","I8244","I8249","I824Y
","I824Z","I8250","I8251","I8252","I8253","I8254","I8259","I825Y","I825Z","I8260","I8261","I8262","I8270","I8271","
I8272","I8281","I8289","I8290","I8291","I82A1","I82A2","I82B1","I82B2","I82C1","I82C2","Z8671","Z8672"

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;I'm hoping some experts here could help me fix my errors and your&amp;nbsp;inputs&amp;nbsp;will be highly appreciated. Thank you so much!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 30 Jan 2018 22:11:12 GMT</pubDate>
    <dc:creator>Crystal_F</dc:creator>
    <dc:date>2018-01-30T22:11:12Z</dc:date>
    <item>
      <title>coding error: how to create a list of values by using sql into: properly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/coding-error-how-to-create-a-list-of-values-by-using-sql-into/m-p/432536#M281794</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a problem creating a&amp;nbsp;macro variable made up of values in different length needed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here I tried to store the list of&amp;nbsp; icd10 code corresponding to a certain value of another variable called ccs10Cat.&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(compress(icd10Code)) format $7., "CCS10_&amp;amp;ccsValue."
         into  :icd10list separated by ",", 
               :ccs10Var
	        from Ccs.Icd10ccsmapping
		       where compress(ccs10Cat) in ("&amp;amp;ccsValue.");
   quit;

   %put &amp;amp;icd10list;
   %put &amp;amp;ccs10Var;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Ideally, i could save the icd10 codes like&amp;nbsp;&lt;SPAN&gt;'I8000',&amp;nbsp;'I8001', .....'&lt;FONT color="#FF6600"&gt;I80201&lt;/FONT&gt;', '&lt;FONT color="#FF6600"&gt;I80202&lt;/FONT&gt;'........ 'Z86718', 'Z8672' into the list for a value of the corresponding ccs equal to 118.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;In general, an icd10 code could be up to 7 characters in length. But here&amp;nbsp;the maximum that i saved is 5. As you can see the value&amp;nbsp;like "I8012" was supposed to be&amp;nbsp;'&lt;FONT color="#FF6600"&gt;I80201&lt;/FONT&gt;'.&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;SYMBOLGEN: Macro variable ICD10LIST resolves to
"I8000","I8001","I8002","I8003","I8010","I8011","I8012","I8013","I8020","I8021","I8022","I8023","I8029","I803","I80
8","I809","I81","I820","I821","I8221","I8222","I8229","I823","I8240","I8241","I8242","I8243","I8244","I8249","I824Y
","I824Z","I8250","I8251","I8252","I8253","I8254","I8259","I825Y","I825Z","I8260","I8261","I8262","I8270","I8271","
I8272","I8281","I8289","I8290","I8291","I82A1","I82A2","I82B1","I82B2","I82C1","I82C2","Z8671","Z8672"

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;I'm hoping some experts here could help me fix my errors and your&amp;nbsp;inputs&amp;nbsp;will be highly appreciated. Thank you so much!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 22:11:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/coding-error-how-to-create-a-list-of-values-by-using-sql-into/m-p/432536#M281794</guid>
      <dc:creator>Crystal_F</dc:creator>
      <dc:date>2018-01-30T22:11:12Z</dc:date>
    </item>
    <item>
      <title>Re: coding error: how to create a list of values by using sql into: properly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/coding-error-how-to-create-a-list-of-values-by-using-sql-into/m-p/432539#M281795</link>
      <description>&lt;P&gt;I'm not sure how the rules of formatting apply here, but it looks like you need to expand your format to $9. instead of $7.&amp;nbsp; It looks like SAS thinks the quotes are part of the formatted length.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 22:16:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/coding-error-how-to-create-a-list-of-values-by-using-sql-into/m-p/432539#M281795</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-01-30T22:16:26Z</dc:date>
    </item>
    <item>
      <title>Re: coding error: how to create a list of values by using sql into: properly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/coding-error-how-to-create-a-list-of-values-by-using-sql-into/m-p/432562#M281796</link>
      <description>&lt;P&gt;How is that macro variable going to be used? With both quotes and commas I foresee some potential issues passing it around in some code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 23:23:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/coding-error-how-to-create-a-list-of-values-by-using-sql-into/m-p/432562#M281796</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-01-30T23:23:03Z</dc:date>
    </item>
    <item>
      <title>Re: coding error: how to create a list of values by using sql into: properly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/coding-error-how-to-create-a-list-of-values-by-using-sql-into/m-p/432785#M281797</link>
      <description>Hi Astounding,&lt;BR /&gt;&lt;BR /&gt;As always, thank you so much for your help! It fixed my problem. Now the code works.</description>
      <pubDate>Wed, 31 Jan 2018 15:23:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/coding-error-how-to-create-a-list-of-values-by-using-sql-into/m-p/432785#M281797</guid>
      <dc:creator>Crystal_F</dc:creator>
      <dc:date>2018-01-31T15:23:36Z</dc:date>
    </item>
    <item>
      <title>Re: coding error: how to create a list of values by using sql into: properly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/coding-error-how-to-create-a-list-of-values-by-using-sql-into/m-p/432791#M281798</link>
      <description>&lt;P&gt;Hi Ballardw,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for bringing this issue to my attention. May i ask what potential issue that you think of? I use the icd10list created to capture diagnosis for Phlebitis as inpatient complication from the claim data. Once a diagnosis code of a claim is found in the list and other criterion are met, the patient will be defined as having Phlebitis as inpatient complication. The relevant code is like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;         else if version[s] eq '0' and dx[s] in (&amp;amp;icd10list) and present[s] ne 'Y' then &amp;amp;ccs10Var. =1;


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Thank you for sharing your thoughts!&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2018 15:35:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/coding-error-how-to-create-a-list-of-values-by-using-sql-into/m-p/432791#M281798</guid>
      <dc:creator>Crystal_F</dc:creator>
      <dc:date>2018-01-31T15:35:03Z</dc:date>
    </item>
    <item>
      <title>Re: coding error: how to create a list of values by using sql into: properly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/coding-error-how-to-create-a-list-of-values-by-using-sql-into/m-p/432810#M281800</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/82725"&gt;@Crystal_F&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi Ballardw,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for bringing this issue to my attention. May i ask what potential issue that you think of? I use the icd10list created to capture diagnosis for Phlebitis as inpatient complication from the claim data. Once a diagnosis code of a claim is found in the list and other criterion are met, the patient will be defined as having Phlebitis as inpatient complication. The relevant code is like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;         else if version[s] eq '0' and dx[s] in (&amp;amp;icd10list) and present[s] ne 'Y' then &amp;amp;ccs10Var. =1;


&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Thank you for sharing your thoughts!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Sometime a macro value is passed as a parameter to another macro such as :&lt;/P&gt;
&lt;P&gt;%somespecialtask (&amp;amp;icd10list);&lt;/P&gt;
&lt;P&gt;Since you have commas in the macro variable each one in the above line would be treated as a delimiter between macro parameters. If the macro expects a single parameter that generates errors of "more positional parameters found then defined".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next is extracting pieces from the list and then doing comparisons:&lt;/P&gt;
&lt;P&gt;%let thiscode = %scan(&amp;amp;icd10list,1); for example thinking that you will get the first code.&lt;/P&gt;
&lt;PRE&gt;1    %let icd10list = "I8000","I8001","I8002";
2    %let thiscode = %scan(&amp;amp;icd10list,1);
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric
       operand is required. The condition was: "I8001"
ERROR: Argument 2 to macro function %SCAN is not a number.
&lt;/PRE&gt;
&lt;P&gt;The error is because of the comma the second code is treated as the second parameter of the %scan call.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Quotes may be more of an issue when concatenating your macro variable with other values or use with some macro functions that will treat the " as part of the value.&lt;/P&gt;
&lt;P&gt;If the ONLY use is as done with the IN comparison in a data step (issues may arise with the macro IN depending on the value compared) it may not be a problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If my only use was in code such as: &amp;nbsp;&lt;SPAN class="token number"&gt;dx&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;[&lt;/SPAN&gt;s&lt;SPAN class="token punctuation"&gt;]&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;in&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;icd10list&lt;SPAN class="token punctuation"&gt;) I would be very tempted to create a custom format (or several as needed) that would yield a value such a 'Valid' or similar and change the code to&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;put(dx[s],myicdfmt.) = 'Valid'&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;Or an informat that yields 1 for found and 0 otherwise: input(dx[s],myicdinfmt.) . Then the value is true(numeric 1)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;One side effect is if I have to debug this macro with symbolgen and mprint then I do not get multiple lines of codes and the program flow is a tad easier&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2018 16:17:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/coding-error-how-to-create-a-list-of-values-by-using-sql-into/m-p/432810#M281800</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-01-31T16:17:07Z</dc:date>
    </item>
    <item>
      <title>Re: coding error: how to create a list of values by using sql into: properly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/coding-error-how-to-create-a-list-of-values-by-using-sql-into/m-p/432894#M281801</link>
      <description>&lt;P&gt;Hi Ballardw,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for sharing your insights. That's very helpful!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And yes, I only use the macro with the in comparison in a data step to avoid hard typing. But I see your point here. Could you please explain how you format '&lt;SPAN&gt;myicdfmt.' and use it to capture the target diagnosis/condition. The way you use the put function here is new to me and I'd like to know in more details.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you for your help!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2018 20:11:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/coding-error-how-to-create-a-list-of-values-by-using-sql-into/m-p/432894#M281801</guid>
      <dc:creator>Crystal_F</dc:creator>
      <dc:date>2018-01-31T20:11:14Z</dc:date>
    </item>
  </channel>
</rss>

