<?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: Problem with Macrovariable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-Macrovariable/m-p/479907#M123941</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/186452"&gt;@mrzlatan91&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi guys, unfortunately I have a problem using&amp;nbsp;Macrovariables. My datasets look like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note, that every index of Table a represents a corresponding value column of table b.&lt;/P&gt;
&lt;P&gt;That means, that e.g. the values of ID 124 (Index 1) are represented in the column of table b.&lt;/P&gt;
&lt;P&gt;Now, in my macro, I do some checks and want to set some specific value columns to missing.&lt;/P&gt;
&lt;P&gt;To try this, I used the following code:&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;How is 124 "represented" in which column of table b?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you get an error copy the code submitted and the error messages from the log and paste into a code box opened using the forum {I} menu icon to preserve formatting of the error messages.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Show what your desired output would look like for your examples.&lt;/P&gt;
&lt;P&gt;And explain your rules a little. You show a macro variable, &amp;amp;lostid, &amp;nbsp;but not it's value. So we don't know what you might actually be looking for. Is &amp;amp;lostid ever likely to be duplicated in different records of work.a? If so your sql will always select the first index where it appears&amp;nbsp;as written.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your example work.a would have ID value of 3535 for index 4. Is that actually what you intended?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 20 Jul 2018 15:18:38 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-07-20T15:18:38Z</dc:date>
    <item>
      <title>Problem with Macrovariable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-Macrovariable/m-p/479898#M123936</link>
      <description>&lt;P&gt;Hi guys, unfortunately I have a problem using&amp;nbsp;Macrovariables. My datasets look like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; work&lt;SPAN class="token punctuation"&gt;.a&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; &lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt; index &lt;SPAN class="token punctuation"&gt;$&lt;/SPAN&gt; id &lt;SPAN class="token punctuation"&gt;$&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; &lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token keyword"&gt;datalines&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token data string"&gt;1 124 &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token data string"&gt;2 425 &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token data string"&gt;3 364 &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token data string"&gt;4 353&lt;BR /&gt;5 858&lt;BR /&gt;6 954&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;data work.b;&lt;/P&gt;&lt;P&gt;input date $ value1 $ value2 $ value3 $ value4 $ value5 $ value6 $;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;01DEC05 1 5 5 5 3 1&lt;/P&gt;&lt;P&gt;01DEC06 1 4 5 8 8 1&lt;/P&gt;&lt;P&gt;02DEC06 1 2 3 2 2 1&lt;/P&gt;&lt;P&gt;05DEC06 1 1 2 1 2 9&lt;/P&gt;&lt;P&gt;01JAN07 1 1 1 1 1 .&lt;/P&gt;&lt;P&gt;02JAN07 1 2 1 . 1&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note, that every index of Table a represents a corresponding value column of table b.&lt;/P&gt;&lt;P&gt;That means, that e.g. the values of ID 124 (Index 1) are represented in the column of table b.&lt;/P&gt;&lt;P&gt;Now, in my macro, I do some checks and want to set some specific value columns to missing.&lt;/P&gt;&lt;P&gt;To try this, I used the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(First, I selected the ID in :lostid in a step before, but this has worked before)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select index into :currIndex from work.a where id = &amp;amp;lostid;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;after that, I know the index of the id and want to add its column:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data work.b;&lt;/P&gt;&lt;P&gt;set work.b;&lt;/P&gt;&lt;P&gt;value&amp;amp;currIndex = .;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately, I´m getting the following error: Statement is not valid or it is used out of proper order. Does anyone have a suggestion for my problem?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 14:53:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-Macrovariable/m-p/479898#M123936</guid>
      <dc:creator>mrzlatan91</dc:creator>
      <dc:date>2018-07-20T14:53:11Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Macrovariable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-Macrovariable/m-p/479906#M123940</link>
      <description>&lt;P&gt;Run the program again, but put the following line at the top of your program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mprint;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then show us the SASLOG, if you can't figure out the error yourself.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 15:18:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-Macrovariable/m-p/479906#M123940</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-07-20T15:18:26Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Macrovariable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-Macrovariable/m-p/479907#M123941</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/186452"&gt;@mrzlatan91&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi guys, unfortunately I have a problem using&amp;nbsp;Macrovariables. My datasets look like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note, that every index of Table a represents a corresponding value column of table b.&lt;/P&gt;
&lt;P&gt;That means, that e.g. the values of ID 124 (Index 1) are represented in the column of table b.&lt;/P&gt;
&lt;P&gt;Now, in my macro, I do some checks and want to set some specific value columns to missing.&lt;/P&gt;
&lt;P&gt;To try this, I used the following code:&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;How is 124 "represented" in which column of table b?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you get an error copy the code submitted and the error messages from the log and paste into a code box opened using the forum {I} menu icon to preserve formatting of the error messages.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Show what your desired output would look like for your examples.&lt;/P&gt;
&lt;P&gt;And explain your rules a little. You show a macro variable, &amp;amp;lostid, &amp;nbsp;but not it's value. So we don't know what you might actually be looking for. Is &amp;amp;lostid ever likely to be duplicated in different records of work.a? If so your sql will always select the first index where it appears&amp;nbsp;as written.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your example work.a would have ID value of 3535 for index 4. Is that actually what you intended?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 15:18:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-Macrovariable/m-p/479907#M123941</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-07-20T15:18:38Z</dc:date>
    </item>
  </channel>
</rss>

