<?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: Macro with the list of variables initialization in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-with-the-list-of-variables-initialization/m-p/313512#M68133</link>
    <description>&lt;P&gt;It is not problem with the case sensitive variables or anything like that. I believe, if not matched, it would still produce an&amp;nbsp;empty table. The problem I tried to describe is that there is no Output tab (and no produced tables in the destination, after running the code, only Log tab appears so I end up with Program tab and Log tab...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/13166i758EF3D6FD4C645F/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="picture1.png" title="picture1.png" /&gt;</description>
    <pubDate>Tue, 22 Nov 2016 16:12:56 GMT</pubDate>
    <dc:creator>Uknown_user</dc:creator>
    <dc:date>2016-11-22T16:12:56Z</dc:date>
    <item>
      <title>Macro with the list of variables initialization</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-with-the-list-of-variables-initialization/m-p/313493#M68124</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to figure out why this code does not return any output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; m(country);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;data work.preselection_&amp;amp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;country.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;set DM_CMDM.VW_CONSUMER (where= (pk_country_id = &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"&amp;amp;country."&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;) keep=pk_country_id pk_consumer_id lk_classmarket personal_marketing PERMANENT_CTRL_GROUP_FLAG GENERAL_MARKETING);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; m;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; &lt;STRONG&gt;&lt;I&gt;Demo&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;PROC SQL noprint;&lt;/P&gt;&lt;P&gt;select distinct pk_country_id&lt;/P&gt;&lt;P&gt;into :country1 - :country999&lt;/P&gt;&lt;P&gt;from DM_CMDM.VW_CONSUMER;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%do&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; I = &lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%to&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;SqlObs.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; %m(&amp;amp;&amp;amp;country&amp;amp;I.);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%end&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; Demo;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;Demo&lt;/I&gt;&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;It probably does exactly what I want it to do but fails to return any output...Here is the message from log:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data work.preselection_AT; set DM_CMDM.VW_CONSUMER (where= (pk_country_id = "AT") keep=pk_country_id pk_consumer_id lk_classmarket&lt;/P&gt;&lt;P&gt;personal_marketing PERMANENT_CTRL_GROUP_FLAG GENERAL_MARKETING); run;&lt;/P&gt;&lt;P&gt;data work.preselection_BG; set DM_CMDM.VW_CONSUMER (where= (pk_country_id = "BG") keep=pk_country_id pk_consumer_id lk_classmarket&lt;/P&gt;&lt;P&gt;personal_marketing PERMANENT_CTRL_GROUP_FLAG GENERAL_MARKETING); run;&lt;/P&gt;&lt;P&gt;data work.preselection_CH; set DM_CMDM.VW_CONSUMER (where= (pk_country_id = "CH") keep=pk_country_id pk_consumer_id lk_classmarket&lt;/P&gt;&lt;P&gt;personal_marketing PERMANENT_CTRL_GROUP_FLAG GENERAL_MARKETING); run;&lt;/P&gt;&lt;P&gt;data work.preselection_CZ; set DM_CMDM.VW_CONSUMER (where= (pk_country_id = "CZ") keep=pk_country_id pk_consumer_id lk_classmarket&lt;/P&gt;&lt;P&gt;personal_marketing PERMANENT_CTRL_GROUP_FLAG GENERAL_MARKETING); run;&lt;/P&gt;&lt;P&gt;data work.preselection_DE; set DM_CMDM.VW_CONSUMER (where= (pk_country_id = "DE") keep=pk_country_id pk_consumer_id lk_classmarket&lt;/P&gt;&lt;P&gt;personal_marketing PERMANENT_CTRL_GROUP_FLAG GENERAL_MARKETING); run;&lt;/P&gt;&lt;P&gt;data work.preselection_HK; set DM_CMDM.VW_CONSUMER (where= (pk_country_id = "HK") keep=pk_country_id pk_consumer_id lk_classmarket&lt;/P&gt;&lt;P&gt;personal_marketing PERMANENT_CTRL_GROUP_FLAG GENERAL_MARKETING); run;&lt;/P&gt;&lt;P&gt;data work.preselection_HU; set DM_CMDM.VW_CONSUMER (where= (pk_country_id = "HU") keep=pk_country_id pk_consumer_id lk_classmarket&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It apparently creates the list of countries but no final files are given back at the end. Any suggestions? Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jiri&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2016 15:28:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-with-the-list-of-variables-initialization/m-p/313493#M68124</guid>
      <dc:creator>Uknown_user</dc:creator>
      <dc:date>2016-11-22T15:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: Macro with the list of variables initialization</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-with-the-list-of-variables-initialization/m-p/313504#M68130</link>
      <description>&lt;P&gt;You haven't posted any test data so can't see what pk_country_id contains, are you sure the where works?&lt;/P&gt;
&lt;P&gt;Secondly, its rarely a good idea to split your data up, just looking at the code to split it, you now need to replicate all that each time to use the data. &amp;nbsp;By processing is both quicker, easy to program and simpler.&lt;/P&gt;
&lt;P&gt;You could simplfy your code somewhat:&lt;/P&gt;
&lt;PRE&gt;proc sort data=dm_cmdm.vw_consumer out=loop nodupkey;
  by pk_country_id;
run;
data _null_;
  set loop;
  call execute(cats('data work.preselection_',pk_country_id,'; set dm_cmdm.vw_consumer (where=(pk_country_id="',pk_country_id,'";run;'));
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 Nov 2016 15:53:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-with-the-list-of-variables-initialization/m-p/313504#M68130</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-11-22T15:53:48Z</dc:date>
    </item>
    <item>
      <title>Re: Macro with the list of variables initialization</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-with-the-list-of-variables-initialization/m-p/313506#M68131</link>
      <description>&lt;P&gt;Thanks for your reply. If the where statement were not working, either the error would be returned or the empty set of tables would still be produced.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2016 15:57:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-with-the-list-of-variables-initialization/m-p/313506#M68131</guid>
      <dc:creator>Uknown_user</dc:creator>
      <dc:date>2016-11-22T15:57:10Z</dc:date>
    </item>
    <item>
      <title>Re: Macro with the list of variables initialization</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-with-the-list-of-variables-initialization/m-p/313508#M68132</link>
      <description>&lt;P&gt;Sorry, miswording. &amp;nbsp;I don't mean not working, I mean logically it doesn't match. &amp;nbsp;Say for instance your data looks like:&lt;/P&gt;
&lt;P&gt;pk_country_id&lt;/P&gt;
&lt;P&gt;at&lt;/P&gt;
&lt;P&gt;bm&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then the where "AT"="at" will not work, as the case is different. &amp;nbsp;As I can't see your data I can't tell. &amp;nbsp;Maybe there is a space before or after, maybe it is a formatted variable?&lt;/P&gt;
&lt;P&gt;Try where upcase(strip(pk_country_id))="AT".&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2016 16:03:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-with-the-list-of-variables-initialization/m-p/313508#M68132</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-11-22T16:03:53Z</dc:date>
    </item>
    <item>
      <title>Re: Macro with the list of variables initialization</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-with-the-list-of-variables-initialization/m-p/313512#M68133</link>
      <description>&lt;P&gt;It is not problem with the case sensitive variables or anything like that. I believe, if not matched, it would still produce an&amp;nbsp;empty table. The problem I tried to describe is that there is no Output tab (and no produced tables in the destination, after running the code, only Log tab appears so I end up with Program tab and Log tab...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/13166i758EF3D6FD4C645F/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="picture1.png" title="picture1.png" /&gt;</description>
      <pubDate>Tue, 22 Nov 2016 16:12:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-with-the-list-of-variables-initialization/m-p/313512#M68133</guid>
      <dc:creator>Uknown_user</dc:creator>
      <dc:date>2016-11-22T16:12:56Z</dc:date>
    </item>
    <item>
      <title>Re: Macro with the list of variables initialization</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-with-the-list-of-variables-initialization/m-p/313513#M68134</link>
      <description>&lt;P&gt;The word %PUT should not be part of your %DO loop.&amp;nbsp; The loop should just call the macro:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%m (&amp;amp;&amp;amp;country&amp;amp;i.)&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2016 16:11:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-with-the-list-of-variables-initialization/m-p/313513#M68134</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-11-22T16:11:23Z</dc:date>
    </item>
    <item>
      <title>Re: Macro with the list of variables initialization</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-with-the-list-of-variables-initialization/m-p/313516#M68135</link>
      <description>&lt;P&gt;Ah,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding﻿&lt;/a&gt;&amp;nbsp;has it. &amp;nbsp;The %put just puts the resolved text of the macro out to the log, it doesn't execute the code. &amp;nbsp;Its a bit like putting plain text out to your log. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2016 16:16:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-with-the-list-of-variables-initialization/m-p/313516#M68135</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-11-22T16:16:56Z</dc:date>
    </item>
    <item>
      <title>Re: Macro with the list of variables initialization</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-with-the-list-of-variables-initialization/m-p/313518#M68137</link>
      <description>&lt;P&gt;That solved my problem. Thanks very much.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2016 16:23:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-with-the-list-of-variables-initialization/m-p/313518#M68137</guid>
      <dc:creator>Uknown_user</dc:creator>
      <dc:date>2016-11-22T16:23:58Z</dc:date>
    </item>
  </channel>
</rss>

