<?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 code works in SAS studio, but not as user made transformation in DI-Studio in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Macro-code-works-in-SAS-studio-but-not-as-user-made/m-p/495250#M15441</link>
    <description>&lt;P&gt;fantastic, that finally solved all the issues. Thank you so much, this has been driving med insane for the last days, since it worked regular sas code, but not as part of a transformation. Really strange how similar code in anoter transformation works without %unquote()&lt;/P&gt;</description>
    <pubDate>Thu, 13 Sep 2018 12:23:05 GMT</pubDate>
    <dc:creator>Ullsokk</dc:creator>
    <dc:date>2018-09-13T12:23:05Z</dc:date>
    <item>
      <title>Macro code works in SAS studio, but not as user made transformation in DI-Studio</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Macro-code-works-in-SAS-studio-but-not-as-user-made/m-p/495218#M15436</link>
      <description>&lt;P&gt;I have a problem with a macro inside a user made transformation (not user written code).&lt;/P&gt;&lt;P&gt;This is the affected code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data = &amp;amp;var.&amp;amp;i.tmp out=&amp;amp;var.&amp;amp;i. let suffix=&amp;amp;suffix._amt ;
	by cust_id Period ;
	var antall&amp;amp;i.tmp ;
	id prodgrp&amp;amp;i._nm ;
	idlabel ProdGrp&amp;amp;i._label ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But in the log, it looks like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NOTE: Line generated by the macro variable "SUFFIX".
325        _S_amt
             ____
             22
               ____
               202
MPRINT(PRODUKTANT):   proc transpose data = SaldoMin_amt1tmp out=SaldoMin_amt1 let suffix=_S_amt by cust_id Period 
;
MPRINT(PRODUKTANT):   var antall1tmp ;
MPRINT(PRODUKTANT):   id prodgrp1_nm ;
MPRINT(PRODUKTANT):   idlabel ProdGrp1_label ;
MPRINT(PRODUKTANT):   run ;

ERROR 22-322: Syntax error, expecting one of the following: ;, DATA, DELIM, DELIMITER, INDB, LABEL, LET, NAME, OUT, PREFIX, 
              SUFFIX.  

ERROR 202-322: The option or parameter is not recognized and will be ignored.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In the log, the semicolon after the suffix-code, seems to be missing, so the executed code seems to be&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; proc transpose data = SaldoMin_amt1tmp out=SaldoMin_amt1 let suffix=_S_amt by cust_id Period &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Not the expected&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; proc transpose data = SaldoMin_amt1tmp out=SaldoMin_amt1 let suffix=_S_amt ;
by cust_id Period &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It seems like the macro variable &amp;amp;suffix. somhow overwrites the semicolon, no matter if I move it down a few lines.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Sep 2018 10:17:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Macro-code-works-in-SAS-studio-but-not-as-user-made/m-p/495218#M15436</guid>
      <dc:creator>Ullsokk</dc:creator>
      <dc:date>2018-09-13T10:17:45Z</dc:date>
    </item>
    <item>
      <title>Re: Macro code works in SAS studio, but not as user made transformation in DI-Studio</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Macro-code-works-in-SAS-studio-but-not-as-user-made/m-p/495226#M15437</link>
      <description>&lt;P&gt;If there is an already-assigned value for &amp;amp;SUFFIX, the word "let" doesn't belong in the program.&amp;nbsp; Just remove it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Technically, the macro statement would be %LET&amp;nbsp; instead of LET.&amp;nbsp; Either way, just remove it.&amp;nbsp; &amp;nbsp;You're not trying to assign a value to &amp;amp;SUFFIX at that point, you're just trying to use the already-assigned value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Sep 2018 11:14:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Macro-code-works-in-SAS-studio-but-not-as-user-made/m-p/495226#M15437</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-09-13T11:14:10Z</dc:date>
    </item>
    <item>
      <title>Re: Macro code works in SAS studio, but not as user made transformation in DI-Studio</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Macro-code-works-in-SAS-studio-but-not-as-user-made/m-p/495231#M15438</link>
      <description>&lt;P&gt;Great, I just used a legacy code, thought that was just&amp;nbsp;some funny syntax, but removing it makes sense. Removed the let, which didnt affect my code in SAS studio (runs anyway) but removed that previous error in DI-studio.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I still have issues with this part of the macro in DI-studio:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data change&amp;amp;i.;
set &amp;amp;var.&amp;amp;i.tmp;
by cust_id ProdGrp&amp;amp;i._Desc Period;
&amp;amp;nm.Lag&amp;amp;suffix.= lag(antall&amp;amp;i.tmp);
&amp;amp;nm.DIF&amp;amp;suffix. = DIF(antall&amp;amp;i.tmp);
if first.ProdGrp&amp;amp;i._Desc then do;
&amp;amp;nm.Lag&amp;amp;suffix. = .;
&amp;amp;nm.DIF&amp;amp;suffix. = .;
end;
&amp;amp;nm.change_pct = divide(&amp;amp;nm.DIF&amp;amp;suffix. , &amp;amp;nm.Lag&amp;amp;suffix.)*100;
run;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;which looks like this in the SAS DI-studio log, but runs without issue in SAS Studio:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   
MPRINT(PRODUKTANT):   data change1;
MPRINT(PRODUKTANT):   set SaldoMin_amt1tmp;
MPRINT(PRODUKTANT):   by cust_id ProdGrp1_Desc Period;
NOTE: Line generated by the macro variable "SUFFIX".
325         SaldoMinLag_Smin
            ________
            180
MPRINT(PRODUKTANT):   SaldoMinLag_Smin= lag(antall1tmp);
NOTE: Line generated by the macro variable "SUFFIX".
325         SaldoMinDIF_Smin
            ________
            180
10                                                         The SAS System                         13:17 Thursday, September 13, 2018

MPRINT(PRODUKTANT):   SaldoMinDIF_Smin = DIF(antall1tmp);
MPRINT(PRODUKTANT):   if first.ProdGrp1_Desc then do;
NOTE: Line generated by the macro variable "SUFFIX".
325         SaldoMinLag_Smin
            ________
            180
MPRINT(PRODUKTANT):   SaldoMinLag_Smin = .;
NOTE: Line generated by the macro variable "SUFFIX".
325         SaldoMinDIF_Smin
            ________
            180
MPRINT(PRODUKTANT):   SaldoMinDIF_Smin = .;
MPRINT(PRODUKTANT):   end;
NOTE: Line generated by the macro variable "NM".
325         SaldoMinEndring_pct
            ________
            180
MPRINT(PRODUKTANT):   SaldoMinEndring_pct = divide(SaldoMinDIF_Smin , SaldoMinLag_Smin)*100;
MPRINT(PRODUKTANT):   run;

ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Sep 2018 11:28:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Macro-code-works-in-SAS-studio-but-not-as-user-made/m-p/495231#M15438</guid>
      <dc:creator>Ullsokk</dc:creator>
      <dc:date>2018-09-13T11:28:31Z</dc:date>
    </item>
    <item>
      <title>Re: Macro code works in SAS studio, but not as user made transformation in DI-Studio</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Macro-code-works-in-SAS-studio-but-not-as-user-made/m-p/495235#M15439</link>
      <description>&lt;P&gt;While I can't be certain, it appears that some of the macro variables may have been quoted when they were created, and the software doesn't figure out how to unquote them in time.&amp;nbsp; If that's the problem, this should fix it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token operator"&gt;%unquote(&amp;amp;&lt;/SPAN&gt;nm&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Lag&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;suffix&lt;SPAN class="token punctuation"&gt;.)&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;lag&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;antall&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;i&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;tmp&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token operator"&gt;%unquote(&amp;amp;&lt;/SPAN&gt;nm&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token procnames"&gt;DIF&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;suffix&lt;SPAN class="token punctuation"&gt;.)&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;DIF&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;antall&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;i&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;tmp&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Sep 2018 11:44:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Macro-code-works-in-SAS-studio-but-not-as-user-made/m-p/495235#M15439</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-09-13T11:44:55Z</dc:date>
    </item>
    <item>
      <title>Re: Macro code works in SAS studio, but not as user made transformation in DI-Studio</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Macro-code-works-in-SAS-studio-but-not-as-user-made/m-p/495250#M15441</link>
      <description>&lt;P&gt;fantastic, that finally solved all the issues. Thank you so much, this has been driving med insane for the last days, since it worked regular sas code, but not as part of a transformation. Really strange how similar code in anoter transformation works without %unquote()&lt;/P&gt;</description>
      <pubDate>Thu, 13 Sep 2018 12:23:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Macro-code-works-in-SAS-studio-but-not-as-user-made/m-p/495250#M15441</guid>
      <dc:creator>Ullsokk</dc:creator>
      <dc:date>2018-09-13T12:23:05Z</dc:date>
    </item>
  </channel>
</rss>

