<?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 %let list = &amp;quot;X&amp;quot;; -&amp;gt; Literal Contains Unmatched Quote Part 2 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/let-list-quot-X-quot-gt-Literal-Contains-Unmatched-Quote-Part-2/m-p/585220#M166853</link>
    <description>&lt;P&gt;A follow-up to:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Programming/let-list-quot-X-quot-gt-Literal-Contains-Unmatched-Quote/td-p/585064" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Programming/let-list-quot-X-quot-gt-Literal-Contains-Unmatched-Quote/td-p/585064&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The arrays (not_done_list, col_list, query_list, sas_check) are all aligned so that the same indexed value corresponds with each other.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let not_done_list = SODIUMND | SODIUMND; /*column names (ND=NOT DONE) */
%let col_list      =  SODIUM | SODIUM ;   /*column names */
&lt;BR /&gt;/* query_list and sas_check are just strings in array, not column names */  &lt;BR /&gt;  &lt;BR /&gt;%let query_list= 'querytext1' | 'querytext2' ;
%let sas_check = "CHEM005" | "CHEM006"; 
&lt;BR /&gt;
%macro create_table(not_done_list, col_list, query_list, sas_check);
proc sql noprint;
CREATE TABLE t1 AS 
SELECT DISTINCT %str(&amp;amp;query_list) as query_text, %str(&amp;amp;sas_check) as SAS_Check, Subject, %str(&amp;amp;not_done_list) as not_done_list, %str(&amp;amp;col_list) as col_list
FROM chem
GROUP BY Subject
HAVING ((put(&amp;amp;col_list, best.)^="" or put(&amp;amp;col_list, best.)="No") and not_done_list IS NOT NULL) OR 
((put(col_list, best.)="" or put(&amp;amp;col_list, best.)="Yes") and not_done_list IS NOT NULL)
;
quit;

%mend create_table;
 

%macro prep_table(notdone, col, query, sas_check );
%local item;
%do item=1 %to %sysfunc(countw(&amp;amp;not_done_list));
	%let notdone=%scan(&amp;amp;not_done_list,&amp;amp;item);
   	%let col=%scan(&amp;amp;col_list,&amp;amp;item);
	%let query=%scan(&amp;amp;query_list,&amp;amp;item, |);
 	%let sas=%scan(&amp;amp;sas_check,&amp;amp;item, |);

	%create_table(not_done_list=&amp;amp;notdone, col_list=&amp;amp;col, query_list=&amp;amp;query, sas_check=&amp;amp;sas);
%end;
%mend prep_table;

%prep_table(notdone=&amp;amp;not_done_list, col=&amp;amp;col_list, query=&amp;amp;query_list, sas_check=&amp;amp;sas_check );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example Input:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;╔═════════╦══════════╦════════╗
║ Subject ║ SODIUMND ║ SODIUM ║
╠═════════╬══════════╬════════╣
║     001 ║ No       ║        ║
║     001 ║ Yes      ║        ║
║     002 ║ Yes      ║    221 ║
║     002 ║ No       ║        ║
╚═════════╩══════════╩════════╝&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No error log, but (not expected) Output:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;╔════════════╦═══════════╦═════════╦═══════════════╦══════════╗
║ query_text ║ SAS_Check ║ Subject ║ not_done_list ║ col_list ║
╠════════════╬═══════════╬═════════╬═══════════════╬══════════╣
║ querytext1 ║   CHEM005 ║     001 ║ No            ║          ║
║ querytext1 ║   CHEM005 ║     002 ║ Yes           ║      221 ║
║ querytext1 ║   CHEM005 ║     002 ║ No            ║          ║
╚════════════╩═══════════╩═════════╩═══════════════╩══════════╝&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;What's wrong:&lt;BR /&gt;1. Only querytext1 is outputted (there is dirty data for querytext2, but no output).&lt;/P&gt;&lt;P&gt;2. &lt;STRIKE&gt;SAS_Check isn't right, it should be the corresponding SAS_Check via the same index in all the arrays.&amp;nbsp;&lt;/STRIKE&gt;&lt;/P&gt;&lt;P&gt;3. not_done_list and col_list should be the value as a string&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Expected output:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;╔════════════╦═══════════╦═════════╦══════════╦════════╗
║ query_text ║ SAS_Check ║ Subject ║ SODIUMND ║ SODIUM ║
╠════════════╬═══════════╬═════════╬══════════╬════════╣
║ querytext1 ║ CHEM005   ║     001 ║ No       ║        ║
║ querytext1 ║ CHEM005   ║     002 ║ Yes      ║    221 ║
║ querytext2 ║ CHEM006   ║     002 ║ No       ║        ║
╚════════════╩═══════════╩═════════╩══════════╩════════╝&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So, if there's a third, different column name in&amp;nbsp;not_done_list and col_list, then it would be like&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;╔════════════╦═══════════╦═════════╦══════════╦════════╦═════════╦═══════╗
║ query_text ║ SAS_Check ║ Subject ║ SODIUMND ║ SODIUM ║ thirdND ║ third ║
╠════════════╬═══════════╬═════════╬══════════╬════════╬═════════╬═══════╣
║ querytext1 ║ CHEM005   ║     001 ║ No       ║        ║         ║       ║
║ querytext1 ║ CHEM005   ║     002 ║ Yes      ║    221 ║         ║       ║
║ querytext2 ║ CHEM006   ║     002 ║ No       ║        ║         ║       ║
╚════════════╩═══════════╩═════════╩══════════╩════════╩═════════╩═══════╝&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know this is a lot to ask, but I'm just stuck.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 30 Aug 2019 15:04:12 GMT</pubDate>
    <dc:creator>jerrylshen</dc:creator>
    <dc:date>2019-08-30T15:04:12Z</dc:date>
    <item>
      <title>%let list = "X"; -&gt; Literal Contains Unmatched Quote Part 2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/let-list-quot-X-quot-gt-Literal-Contains-Unmatched-Quote-Part-2/m-p/585220#M166853</link>
      <description>&lt;P&gt;A follow-up to:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Programming/let-list-quot-X-quot-gt-Literal-Contains-Unmatched-Quote/td-p/585064" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Programming/let-list-quot-X-quot-gt-Literal-Contains-Unmatched-Quote/td-p/585064&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The arrays (not_done_list, col_list, query_list, sas_check) are all aligned so that the same indexed value corresponds with each other.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let not_done_list = SODIUMND | SODIUMND; /*column names (ND=NOT DONE) */
%let col_list      =  SODIUM | SODIUM ;   /*column names */
&lt;BR /&gt;/* query_list and sas_check are just strings in array, not column names */  &lt;BR /&gt;  &lt;BR /&gt;%let query_list= 'querytext1' | 'querytext2' ;
%let sas_check = "CHEM005" | "CHEM006"; 
&lt;BR /&gt;
%macro create_table(not_done_list, col_list, query_list, sas_check);
proc sql noprint;
CREATE TABLE t1 AS 
SELECT DISTINCT %str(&amp;amp;query_list) as query_text, %str(&amp;amp;sas_check) as SAS_Check, Subject, %str(&amp;amp;not_done_list) as not_done_list, %str(&amp;amp;col_list) as col_list
FROM chem
GROUP BY Subject
HAVING ((put(&amp;amp;col_list, best.)^="" or put(&amp;amp;col_list, best.)="No") and not_done_list IS NOT NULL) OR 
((put(col_list, best.)="" or put(&amp;amp;col_list, best.)="Yes") and not_done_list IS NOT NULL)
;
quit;

%mend create_table;
 

%macro prep_table(notdone, col, query, sas_check );
%local item;
%do item=1 %to %sysfunc(countw(&amp;amp;not_done_list));
	%let notdone=%scan(&amp;amp;not_done_list,&amp;amp;item);
   	%let col=%scan(&amp;amp;col_list,&amp;amp;item);
	%let query=%scan(&amp;amp;query_list,&amp;amp;item, |);
 	%let sas=%scan(&amp;amp;sas_check,&amp;amp;item, |);

	%create_table(not_done_list=&amp;amp;notdone, col_list=&amp;amp;col, query_list=&amp;amp;query, sas_check=&amp;amp;sas);
%end;
%mend prep_table;

%prep_table(notdone=&amp;amp;not_done_list, col=&amp;amp;col_list, query=&amp;amp;query_list, sas_check=&amp;amp;sas_check );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example Input:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;╔═════════╦══════════╦════════╗
║ Subject ║ SODIUMND ║ SODIUM ║
╠═════════╬══════════╬════════╣
║     001 ║ No       ║        ║
║     001 ║ Yes      ║        ║
║     002 ║ Yes      ║    221 ║
║     002 ║ No       ║        ║
╚═════════╩══════════╩════════╝&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No error log, but (not expected) Output:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;╔════════════╦═══════════╦═════════╦═══════════════╦══════════╗
║ query_text ║ SAS_Check ║ Subject ║ not_done_list ║ col_list ║
╠════════════╬═══════════╬═════════╬═══════════════╬══════════╣
║ querytext1 ║   CHEM005 ║     001 ║ No            ║          ║
║ querytext1 ║   CHEM005 ║     002 ║ Yes           ║      221 ║
║ querytext1 ║   CHEM005 ║     002 ║ No            ║          ║
╚════════════╩═══════════╩═════════╩═══════════════╩══════════╝&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;What's wrong:&lt;BR /&gt;1. Only querytext1 is outputted (there is dirty data for querytext2, but no output).&lt;/P&gt;&lt;P&gt;2. &lt;STRIKE&gt;SAS_Check isn't right, it should be the corresponding SAS_Check via the same index in all the arrays.&amp;nbsp;&lt;/STRIKE&gt;&lt;/P&gt;&lt;P&gt;3. not_done_list and col_list should be the value as a string&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Expected output:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;╔════════════╦═══════════╦═════════╦══════════╦════════╗
║ query_text ║ SAS_Check ║ Subject ║ SODIUMND ║ SODIUM ║
╠════════════╬═══════════╬═════════╬══════════╬════════╣
║ querytext1 ║ CHEM005   ║     001 ║ No       ║        ║
║ querytext1 ║ CHEM005   ║     002 ║ Yes      ║    221 ║
║ querytext2 ║ CHEM006   ║     002 ║ No       ║        ║
╚════════════╩═══════════╩═════════╩══════════╩════════╝&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So, if there's a third, different column name in&amp;nbsp;not_done_list and col_list, then it would be like&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;╔════════════╦═══════════╦═════════╦══════════╦════════╦═════════╦═══════╗
║ query_text ║ SAS_Check ║ Subject ║ SODIUMND ║ SODIUM ║ thirdND ║ third ║
╠════════════╬═══════════╬═════════╬══════════╬════════╬═════════╬═══════╣
║ querytext1 ║ CHEM005   ║     001 ║ No       ║        ║         ║       ║
║ querytext1 ║ CHEM005   ║     002 ║ Yes      ║    221 ║         ║       ║
║ querytext2 ║ CHEM006   ║     002 ║ No       ║        ║         ║       ║
╚════════════╩═══════════╩═════════╩══════════╩════════╩═════════╩═══════╝&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know this is a lot to ask, but I'm just stuck.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2019 15:04:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/let-list-quot-X-quot-gt-Literal-Contains-Unmatched-Quote-Part-2/m-p/585220#M166853</guid>
      <dc:creator>jerrylshen</dc:creator>
      <dc:date>2019-08-30T15:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: %let list = "X"; -&gt; Literal Contains Unmatched Quote Part 2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/let-list-quot-X-quot-gt-Literal-Contains-Unmatched-Quote-Part-2/m-p/585225#M166858</link>
      <description>&lt;P&gt;Please post dataset chem in a data step with datalines.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2019 14:39:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/let-list-quot-X-quot-gt-Literal-Contains-Unmatched-Quote-Part-2/m-p/585225#M166858</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-08-30T14:39:39Z</dc:date>
    </item>
    <item>
      <title>Re: %let list = "X"; -&gt; Literal Contains Unmatched Quote Part 2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/let-list-quot-X-quot-gt-Literal-Contains-Unmatched-Quote-Part-2/m-p/585228#M166861</link>
      <description>&lt;P&gt;Added an input to main post, thanks&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2019 14:45:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/let-list-quot-X-quot-gt-Literal-Contains-Unmatched-Quote-Part-2/m-p/585228#M166861</guid>
      <dc:creator>jerrylshen</dc:creator>
      <dc:date>2019-08-30T14:45:15Z</dc:date>
    </item>
    <item>
      <title>Re: %let list = "X"; -&gt; Literal Contains Unmatched Quote Part 2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/let-list-quot-X-quot-gt-Literal-Contains-Unmatched-Quote-Part-2/m-p/585238#M166866</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/277351"&gt;@jerrylshen&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;A follow-up to:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Programming/let-list-quot-X-quot-gt-Literal-Contains-Unmatched-Quote/td-p/585064" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Programming/let-list-quot-X-quot-gt-Literal-Contains-Unmatched-Quote/td-p/585064&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The arrays (not_done_list, col_list, query_list, sas_check) are all aligned so that the same indexed value corresponds with each other.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let not_done_list = SODIUMND | SODIUMND; /*column names (ND=NOT DONE) */
%let col_list      =  SODIUM | SODIUM ;   /*column names */
&lt;BR /&gt;/* query_list and sas_check are just strings in array, not column names */  &lt;BR /&gt;  &lt;BR /&gt;%let query_list= 'querytext1' | 'querytext2' ;
%let sas_check = "CHEM005" | "CHEM006"; 
&lt;BR /&gt;
%macro create_table(not_done_list, col_list, query_list, sas_check);
proc sql noprint;
CREATE TABLE t1 AS 
SELECT DISTINCT %str(&amp;amp;query_list) as query_text, %str(&amp;amp;sas_check) as SAS_Check, Subject, %str(&amp;amp;not_done_list) as not_done_list, %str(&amp;amp;col_list) as col_list
FROM chem
GROUP BY Subject
HAVING ((put(&amp;amp;col_list, best.)^="" or put(&amp;amp;col_list, best.)="No") and not_done_list IS NOT NULL) OR 
((put(col_list, best.)="" or put(&amp;amp;col_list, best.)="Yes") and not_done_list IS NOT NULL)
;
quit;

%mend create_table;
 

%macro prep_table(notdone, col, query, sas_check );
%local item;
%do item=1 %to %sysfunc(countw(&amp;amp;not_done_list));
	%let notdone=%scan(&amp;amp;not_done_list,&amp;amp;item);
   	%let col=%scan(&amp;amp;col_list,&amp;amp;item);
	%let query=%scan(&amp;amp;query_list,&amp;amp;item, |);
 	%let sas=%scan(&amp;amp;sas_check,&amp;amp;item, |);

	%create_table(not_done_list=&amp;amp;notdone, col_list=&amp;amp;col, query_list=&amp;amp;query, sas_check=&amp;amp;sas_check );
%end;
%mend prep_table;

%prep_table(notdone=&amp;amp;not_done_list, col=&amp;amp;col_list, query=&amp;amp;query_list, sas_check=&amp;amp;sas_check );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example Input:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;╔═════════╦══════════╦════════╗
║ Subject ║ SODIUMND ║ SODIUM ║
╠═════════╬══════════╬════════╣
║     001 ║ No       ║        ║
║     001 ║ Yes      ║        ║
║     002 ║ Yes      ║    221 ║
║     002 ║ No       ║        ║
╚═════════╩══════════╩════════╝&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;No error log, but (not expected) Output:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;╔════════════╦═══════════╦═════════╦═══════════════╦══════════╗
║ query_text ║ SAS_Check ║ Subject ║ not_done_list ║ col_list ║
╠════════════╬═══════════╬═════════╬═══════════════╬══════════╣
║ querytext1 ║         1 ║     001 ║ No            ║          ║
║ querytext1 ║         1 ║     002 ║ Yes           ║      221 ║
║ querytext1 ║         1 ║     002 ║ No            ║          ║
╚════════════╩═══════════╩═════════╩═══════════════╩══════════╝&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What's wrong:&lt;BR /&gt;1. Only querytext1 is outputted (there is dirty data for querytext2, but no output).&lt;/P&gt;
&lt;P&gt;2. SAS_Check isn't right, it should be the corresponding SAS_Check via the same index in all the arrays.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. not_done_list and col_list should be the value as a string&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Expected output:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;╔════════════╦═══════════╦═════════╦══════════╦════════╗
║ query_text ║ SAS_Check ║ Subject ║ SODIUMND ║ SODIUM ║
╠════════════╬═══════════╬═════════╬══════════╬════════╣
║ querytext1 ║ CHEM005   ║     001 ║ No       ║        ║
║ querytext1 ║ CHEM005   ║     002 ║ Yes      ║    221 ║
║ querytext2 ║ CHEM006   ║     002 ║ No       ║        ║
╚════════════╩═══════════╩═════════╩══════════╩════════╝&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So, if there's a third, different column name in&amp;nbsp;not_done_list and col_list, then it would be like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;╔════════════╦═══════════╦═════════╦══════════╦════════╦═════════╦═══════╗
║ query_text ║ SAS_Check ║ Subject ║ SODIUMND ║ SODIUM ║ thirdND ║ third ║
╠════════════╬═══════════╬═════════╬══════════╬════════╬═════════╬═══════╣
║ querytext1 ║ CHEM005   ║     001 ║ No       ║        ║         ║       ║
║ querytext1 ║ CHEM005   ║     002 ║ Yes      ║    221 ║         ║       ║
║ querytext2 ║ CHEM006   ║     002 ║ No       ║        ║         ║       ║
╚════════════╩═══════════╩═════════╩══════════╩════════╩═════════╩═══════╝&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know this is a lot to ask, but I'm just stuck.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;First thing the BEST format displays numeric values. So this&lt;/P&gt;
&lt;PRE&gt;put(&amp;amp;col_list, best.)="No"&lt;/PRE&gt;
&lt;P&gt;Is &lt;FONT color="#ff00ff" size="5"&gt;&lt;STRONG&gt;NEVER&lt;/STRONG&gt; &lt;/FONT&gt;true.&lt;/P&gt;
&lt;P&gt;One of the nice things about SAS though not obvious to beginner is that non-zero values are "true"&lt;/P&gt;
&lt;PRE&gt;data example;
   input x;
   if x then put x= "is true";
datalines;
1
0
.
123
.45
1E35
;
run;&lt;/PRE&gt;
&lt;P&gt;So instead of that very awkward construct other comparisons are appropriate. But since you still have provided no actual data in the form of a data step with expected results for that I can't tell what values&amp;nbsp;you intended with your "No" or "Yes" comparisons.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Similar:&lt;/P&gt;
&lt;PRE&gt;(put(&amp;amp;col_list, best.)^=""&lt;/PRE&gt;
&lt;P&gt;way easier to test with Not missing(&amp;amp;col_list.) (assuming &amp;amp;col_list is a valid SINGLE variable. Big advantage, the Missing function will behavior correctly with numeric or character variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And can you show us the code that "worked" as intended without any macros or&amp;nbsp;macro variables before you delved into writing these macros. Hint: With data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2019 15:15:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/let-list-quot-X-quot-gt-Literal-Contains-Unmatched-Quote-Part-2/m-p/585238#M166866</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-08-30T15:15:50Z</dc:date>
    </item>
    <item>
      <title>Re: %let list = "X"; -&gt; Literal Contains Unmatched Quote Part 2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/let-list-quot-X-quot-gt-Literal-Contains-Unmatched-Quote-Part-2/m-p/585250#M166874</link>
      <description>&lt;P&gt;I suggest you start by getting %Create_Table to work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Actually, start by getting the PROC SQL step inside of %Create_Table to work, when you just write the PROC SQL step with NO MACRO CODE.&amp;nbsp; As shown, there are some problems in your SQL logic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then after you are happy with the PROC SQL step, write %Create_Table.&amp;nbsp; Note that the parameter names you have now in create_table are odd.&amp;nbsp; They have _list as a suffix, but you don't pass a list to them as an argument, you only pass a single item.&amp;nbsp; This makes things more confusing later when you introduce lists.&amp;nbsp; Also you don't need %STR() on your select distinct clause.&amp;nbsp; &amp;nbsp;Keep working on %Create_Table until you can write the two macro calls for CHEM005 and CHEM006, and get the results you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then after that, work on %PREP_table.&amp;nbsp; &amp;nbsp;This macro has a weird name, it's really a driver for %CreateTable.&amp;nbsp; It could be %CreateLotsOfTables.&amp;nbsp; A bigger issue in your current version is that it has a parameter named notdone which should probably be notdone_list.&amp;nbsp; Because this macro *does* take lists as a parameter.&amp;nbsp; As it's written, the macro doesn't actually use the parameter values it is passed as arguments, it uses the global macro variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Macro language is hard.&amp;nbsp; When you hit errors, you have to debug in two languages.&amp;nbsp; It's often easier to start by getting working SAS code, then write a macro.&amp;nbsp; And this case, then writes a second macro to call the first macros.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2019 15:37:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/let-list-quot-X-quot-gt-Literal-Contains-Unmatched-Quote-Part-2/m-p/585250#M166874</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2019-08-30T15:37:11Z</dc:date>
    </item>
  </channel>
</rss>

