<?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: Question on creating a macro variable for loading comma separated list of values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Question-on-creating-a-macro-variable-for-loading-comma/m-p/675296#M203437</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/272260"&gt;@radhap&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;This is the question, I am copy pasting the question directly&amp;nbsp; from the exam, as is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Use SAS dictionary tables, run a PROC SQL query to create a macro variable named&amp;nbsp;COL_LIST&amp;nbsp;which contains a comma separated list of the columns contained in the&amp;nbsp;CERT.AIR10&amp;nbsp;data set. If needed, use the DESCRIBE TABLE statement to display the column attributes of the dictionary.columns table.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;What is the value of the col_list macro variable? &lt;/STRONG&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So your answer is RIGHT.&amp;nbsp; SQL does not impose an order on the result set unless you request one and they did not ask for one.&amp;nbsp; Acceptable answers could include&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;DATE,AIR
AIR,DATE
&lt;/PRE&gt;
&lt;P&gt;(note the CASE of the letters might be different, depending on how they are in the CERT.AIR10 dataset and whether the VALIDVARNAME option is set to UPCASE).&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;They did not say anything about adding spaces between the values, but if spaces are allowed then you could also generate more permutations of those two answers by including space before, after or on both sides of the comma.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In that case their answer would also be correct.&lt;/P&gt;</description>
    <pubDate>Fri, 07 Aug 2020 20:52:38 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2020-08-07T20:52:38Z</dc:date>
    <item>
      <title>Question on creating a macro variable for loading comma separated list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-on-creating-a-macro-variable-for-loading-comma/m-p/675280#M203426</link>
      <description>&lt;P&gt;I took&amp;nbsp;SAS Advanced practice exam couple of days back and I have some doubts on one question regarding creating a macro variable that contains list of comma-separated values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the question from the exam:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Use SAS dictionary tables, run a PROC SQL query to create a macro variable named&amp;nbsp;COL_LIST&amp;nbsp;which contains a comma separated list of the columns contained in the&amp;nbsp;CERT.AIR10&amp;nbsp;data set. If needed, use the DESCRIBE TABLE statement to display the column attributes of the dictionary.columns table.&amp;nbsp;&lt;STRONG&gt;Question&lt;/STRONG&gt;: What is the value of the col_list macro variable?&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I answered:&lt;/STRONG&gt; DATE,AIR&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Per exam result: &lt;/STRONG&gt;my answer was wrong&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Solution given by SAS:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;proc sql ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;select distinct name into :col_list separated by ', '&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; from dictionary.columns&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;where libname='CERT' and memname="AIR10";&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The correct answer is:&lt;/STRONG&gt; AIR, DATE&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Could someone please help me understand:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Why the ‘distinct’ keyword and 'comma with blank space' are used.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Aug 2020 19:29:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-on-creating-a-macro-variable-for-loading-comma/m-p/675280#M203426</guid>
      <dc:creator>radhap</dc:creator>
      <dc:date>2020-08-07T19:29:43Z</dc:date>
    </item>
    <item>
      <title>Re: Question on creating a macro variable for loading comma separated list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-on-creating-a-macro-variable-for-loading-comma/m-p/675283#M203428</link>
      <description>&lt;P&gt;Distinct so each result only appears once&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you look very closely at the code&lt;/P&gt;
&lt;PRE&gt; by ', '&lt;/PRE&gt;
&lt;P&gt;you can tell that there is a space inside the quotes. Make the font larger or move your cursor and you can see it. The "separated by" can be any string, even something odd like ",,,,word,,,,,". Then the result would be Air,,,,word,,,,,Date&lt;/P&gt;
&lt;P&gt;The "why" of including the space depends on the programmer and probably the likely use of the macro variable. If I am creating a string for parameters I might not include the space but if I intend a human to read the results the space with the comma has a nicer appearance and follows typical text formatting rules.&lt;/P&gt;
&lt;P&gt;And Proc SQL will return the values in sorted order by default. So Air before Date&lt;/P&gt;</description>
      <pubDate>Fri, 07 Aug 2020 19:47:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-on-creating-a-macro-variable-for-loading-comma/m-p/675283#M203428</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-08-07T19:47:27Z</dc:date>
    </item>
    <item>
      <title>Re: Question on creating a macro variable for loading comma separated list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-on-creating-a-macro-variable-for-loading-comma/m-p/675285#M203429</link>
      <description>&lt;P&gt;Here's something you might be able to check ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I believe that SQL returns the values in the order in which they appear in the data.&amp;nbsp; So you might be right about&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATE, AIR&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;except for one thing.&amp;nbsp; Adding the keyword DISTINCT to the SQL query will force SAS to track the values so it makes life easier to track them by alphabetizing the extracted values.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Aug 2020 19:49:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-on-creating-a-macro-variable-for-loading-comma/m-p/675285#M203429</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2020-08-07T19:49:01Z</dc:date>
    </item>
    <item>
      <title>Re: Question on creating a macro variable for loading comma separated list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-on-creating-a-macro-variable-for-loading-comma/m-p/675286#M203430</link>
      <description>&lt;P&gt;Hi Ballardw&lt;/P&gt;&lt;P&gt;Thanks for the quick response. the ', ' is in the answer (key) provided after the exam. But in the question itself, I do not see any hint of the space&lt;/P&gt;</description>
      <pubDate>Fri, 07 Aug 2020 19:51:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-on-creating-a-macro-variable-for-loading-comma/m-p/675286#M203430</guid>
      <dc:creator>radhap</dc:creator>
      <dc:date>2020-08-07T19:51:33Z</dc:date>
    </item>
    <item>
      <title>Re: Question on creating a macro variable for loading comma separated list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-on-creating-a-macro-variable-for-loading-comma/m-p/675287#M203431</link>
      <description>&lt;P&gt;And also, in the question, it does not mention about unique/ distinct values&lt;/P&gt;</description>
      <pubDate>Fri, 07 Aug 2020 19:53:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-on-creating-a-macro-variable-for-loading-comma/m-p/675287#M203431</guid>
      <dc:creator>radhap</dc:creator>
      <dc:date>2020-08-07T19:53:00Z</dc:date>
    </item>
    <item>
      <title>Re: Question on creating a macro variable for loading comma separated list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-on-creating-a-macro-variable-for-loading-comma/m-p/675288#M203432</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/272260"&gt;@radhap&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi Ballardw&lt;/P&gt;
&lt;P&gt;Thanks for the quick response. the ', ' is in the answer (key) provided after the exam. But in the question itself, I do not see any hint of the space&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I would bring that up to who ever provided this information.&lt;/P&gt;
&lt;P&gt;But since we can't see the question in any way then who knows. One of the reasons code really should never appear in proportional fonts is because of things like this. Some fonts can be very hard to tell if a space exists or not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Aug 2020 19:56:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-on-creating-a-macro-variable-for-loading-comma/m-p/675288#M203432</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-08-07T19:56:07Z</dc:date>
    </item>
    <item>
      <title>Re: Question on creating a macro variable for loading comma separated list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-on-creating-a-macro-variable-for-loading-comma/m-p/675295#M203436</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;This is the question, I am copy pasting the question directly&amp;nbsp; from the exam, as is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Use SAS dictionary tables, run a PROC SQL query to create a macro variable named&amp;nbsp;COL_LIST&amp;nbsp;which contains a comma separated list of the columns contained in the&amp;nbsp;CERT.AIR10&amp;nbsp;data set. If needed, use the DESCRIBE TABLE statement to display the column attributes of the dictionary.columns table.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;What is the value of the col_list macro variable? &lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Aug 2020 20:41:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-on-creating-a-macro-variable-for-loading-comma/m-p/675295#M203436</guid>
      <dc:creator>radhap</dc:creator>
      <dc:date>2020-08-07T20:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: Question on creating a macro variable for loading comma separated list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-on-creating-a-macro-variable-for-loading-comma/m-p/675296#M203437</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/272260"&gt;@radhap&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;This is the question, I am copy pasting the question directly&amp;nbsp; from the exam, as is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Use SAS dictionary tables, run a PROC SQL query to create a macro variable named&amp;nbsp;COL_LIST&amp;nbsp;which contains a comma separated list of the columns contained in the&amp;nbsp;CERT.AIR10&amp;nbsp;data set. If needed, use the DESCRIBE TABLE statement to display the column attributes of the dictionary.columns table.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;What is the value of the col_list macro variable? &lt;/STRONG&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So your answer is RIGHT.&amp;nbsp; SQL does not impose an order on the result set unless you request one and they did not ask for one.&amp;nbsp; Acceptable answers could include&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;DATE,AIR
AIR,DATE
&lt;/PRE&gt;
&lt;P&gt;(note the CASE of the letters might be different, depending on how they are in the CERT.AIR10 dataset and whether the VALIDVARNAME option is set to UPCASE).&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;They did not say anything about adding spaces between the values, but if spaces are allowed then you could also generate more permutations of those two answers by including space before, after or on both sides of the comma.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In that case their answer would also be correct.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Aug 2020 20:52:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-on-creating-a-macro-variable-for-loading-comma/m-p/675296#M203437</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-08-07T20:52:38Z</dc:date>
    </item>
    <item>
      <title>Re: Question on creating a macro variable for loading comma separated list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-on-creating-a-macro-variable-for-loading-comma/m-p/675304#M203441</link>
      <description>&lt;P&gt;What was your query?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This topic is covered in depth in the Advanced Prep Certification Guide,Chapter 10.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't like this question because you can answer it correctly WITHOUT knowing how to actually create macro variables from a SQL query.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/272260"&gt;@radhap&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;This is the question, I am copy pasting the question directly&amp;nbsp; from the exam, as is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Use SAS dictionary tables, run a PROC SQL query to create a macro variable named&amp;nbsp;COL_LIST&amp;nbsp;which contains a comma separated list of the columns contained in the&amp;nbsp;CERT.AIR10&amp;nbsp;data set. If needed, use the DESCRIBE TABLE statement to display the column attributes of the dictionary.columns table.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;What is the value of the col_list macro variable? &lt;/STRONG&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Aug 2020 21:30:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-on-creating-a-macro-variable-for-loading-comma/m-p/675304#M203441</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-08-07T21:30:48Z</dc:date>
    </item>
    <item>
      <title>Re: Question on creating a macro variable for loading comma separated list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-on-creating-a-macro-variable-for-loading-comma/m-p/675305#M203442</link>
      <description>&lt;P&gt;Thank you Tom.&lt;/P&gt;&lt;P&gt;I lost 3 points because of not adding distinct keyword&amp;nbsp;before the name variable and space after comma (since they were not asked in the question)&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now i am confused about which approach I should follow in case I get a similar question in the main exam.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Aug 2020 21:36:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-on-creating-a-macro-variable-for-loading-comma/m-p/675305#M203442</guid>
      <dc:creator>radhap</dc:creator>
      <dc:date>2020-08-07T21:36:40Z</dc:date>
    </item>
  </channel>
</rss>

