<?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: Transfer two letters to Macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150869#M29739</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When you refer to a macro variable, you have the option of adding a dot at the end of the name.&amp;nbsp; Both of these resolve to the same thing:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;amp;DOMAIN&lt;/P&gt;&lt;P&gt;&amp;amp;DOMAIN.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want a dot added to your program, use two dots:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;amp;DOMAIN..CAT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 06 Aug 2014 12:56:06 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2014-08-06T12:56:06Z</dc:date>
    <item>
      <title>Transfer two letters to Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150866#M29736</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wanted to transfer two letters to my macro that would be used in data step.&amp;nbsp; Such as:&amp;nbsp; I will define a macro like this:&lt;/P&gt;&lt;P&gt;%MACRO MyMacro(Domain=);&lt;/P&gt;&lt;P&gt;IF UPCASE(STRIP(&amp;amp;DOMAIN))='LB' THEN DO;&lt;/P&gt;&lt;P&gt;&amp;nbsp; LENGTH PARCAT1 $50; &lt;/P&gt;&lt;P&gt;&amp;nbsp; PARCAT1 = STRIP(&amp;amp;DOMAIN.CAT);&lt;/P&gt;&lt;P&gt;&amp;nbsp; END;&lt;/P&gt;&lt;P&gt;%MEND MyMacro;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my program, how should I pass LB to Domain in macro?&amp;nbsp; The following way did not work.&amp;nbsp; Macro facility transfer translate &amp;amp;DOMAIN.CAT to 'LB'CAT.&amp;nbsp; Does any can help to overcome this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data abc;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %MyMacro(Domain='LB');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;Abdu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Aug 2014 00:50:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150866#M29736</guid>
      <dc:creator>Abdu</dc:creator>
      <dc:date>2014-08-06T00:50:47Z</dc:date>
    </item>
    <item>
      <title>Re: Transfer two letters to Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150867#M29737</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You do not need to quote strings when using macros.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data abc;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %MyMacro(Domain=LB);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Aug 2014 06:37:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150867#M29737</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2014-08-06T06:37:31Z</dc:date>
    </item>
    <item>
      <title>Re: Transfer two letters to Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150868#M29738</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If your intention ist to generate PARCAT1 only when DOMAIN=LB, you should rephrase it like that:&lt;/P&gt;&lt;P&gt;%MACRO MyMacro(Domain=);&lt;/P&gt;&lt;P&gt;%IF %UPCASE(&amp;amp;Domain)=LB %THEN %DO;&lt;/P&gt;&lt;P&gt;&amp;nbsp; LENGTH PARCAT1 $50; &lt;/P&gt;&lt;P&gt;&amp;nbsp; PARCAT1 = STRIP(&amp;amp;DOMAIN.CAT);&lt;/P&gt;&lt;P&gt;%END;&lt;/P&gt;&lt;P&gt;%MEND MyMacro;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;options mlogic mprint;&lt;/P&gt;&lt;P&gt;Data abc;&lt;/P&gt;&lt;P&gt;lbcat = 'XXX';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %MyMacro(Domain=LB);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %MyMacro(Domain=LC); * just to show what happens;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;options nomlogic nomprint;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Aug 2014 07:23:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150868#M29738</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2014-08-06T07:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: Transfer two letters to Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150869#M29739</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When you refer to a macro variable, you have the option of adding a dot at the end of the name.&amp;nbsp; Both of these resolve to the same thing:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;amp;DOMAIN&lt;/P&gt;&lt;P&gt;&amp;amp;DOMAIN.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want a dot added to your program, use two dots:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;amp;DOMAIN..CAT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Aug 2014 12:56:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150869#M29739</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-08-06T12:56:06Z</dc:date>
    </item>
    <item>
      <title>Re: Transfer two letters to Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150870#M29740</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kurt/Andreas,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Because I am using the macro in data step, if I call macro like &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%MyMacro(Domain=LB);&lt;/SPAN&gt; I will get an LB uninitial message, and the letter LB was not passed to macro facility.&amp;nbsp; I temporally using this way:&lt;/P&gt;&lt;P&gt;LENGTH LB $2;&lt;/P&gt;&lt;P&gt;LB='LB'; *LB=anything may work as well;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%MyMacro(Domain=LB);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I think there should be other professional way to pass LB to the macro.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another thing bothers me is like Kurt suggested:&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%IF %UPCASE(&amp;amp;Domain)=LB %THEN %DO;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; LENGTH PARCAT1 $50;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; PARCAT1 = STRIP(&amp;amp;DOMAIN.CAT);&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%END;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;I still get missing values for PARCAT1 if I run it with other domain.&amp;nbsp; I guess it is difficult to discard PARCAT1 if I am not working with LB domain.&amp;nbsp; Any suggestions?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for responding.,&lt;/P&gt;&lt;P&gt;Abdu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Aug 2014 13:05:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150870#M29740</guid>
      <dc:creator>Abdu</dc:creator>
      <dc:date>2014-08-06T13:05:53Z</dc:date>
    </item>
    <item>
      <title>Re: Transfer two letters to Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150871#M29741</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Astounding,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I actually want to combine the two part without period in the middle.&lt;/P&gt;&lt;P&gt;Thanks,,&lt;/P&gt;&lt;P&gt;Abdu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Aug 2014 13:06:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150871#M29741</guid>
      <dc:creator>Abdu</dc:creator>
      <dc:date>2014-08-06T13:06:47Z</dc:date>
    </item>
    <item>
      <title>Re: Transfer two letters to Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150872#M29742</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In that case, you should without question pass the value without quotes:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(domain=LB)&lt;/P&gt;&lt;P&gt;The more difficult question is what should the SAS code look like that is generated by macro language?&amp;nbsp; For example, do you want the SAS program to contain:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PARCAT1="LBCAT";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or do you want it to contain:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PARCAT1=LBCAT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That's pretty much the question for any macro language application:&amp;nbsp; what do you want the generated SAS code to look like?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Aug 2014 13:16:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150872#M29742</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-08-06T13:16:15Z</dc:date>
    </item>
    <item>
      <title>Re: Transfer two letters to Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150873#M29743</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want to generate SAS code like:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;PARCAT1=LBCAT;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Please view my previous response to &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Kurt/Andreas&lt;/SPAN&gt;. My trouble part is how to pass 'LB' to macro in data step.&amp;nbsp; I guess I can write an independent macro, but I think a macro used in data step is easier to apply and less trouble.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Thanks,&amp;nbsp; &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Aug 2014 13:23:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150873#M29743</guid>
      <dc:creator>Abdu</dc:creator>
      <dc:date>2014-08-06T13:23:02Z</dc:date>
    </item>
    <item>
      <title>Re: Transfer two letters to Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150874#M29744</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Looking that over, it looks like your macro definition should be different.&amp;nbsp; Use macro %IF/%THEN instead of DATA step IF/THEN:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%if &amp;amp;domain=LB %then %do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; length parcat1 $ 50;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; parcat1=LBCAT;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or, if appropriate, don't use any form of IF/THEN statements:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;length parcat1 $ 50;&lt;/P&gt;&lt;P&gt;parcat1=&amp;amp;domain.CAT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As before, the real issue is what the SAS code is supposed to look like when you call the macro.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Aug 2014 13:34:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150874#M29744</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-08-06T13:34:48Z</dc:date>
    </item>
    <item>
      <title>Re: Transfer two letters to Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150875#M29745</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well,&lt;/P&gt;&lt;P&gt;options mlogic mprint symbolgen;&lt;BR /&gt;%MACRO MyMacro(Domain=);&lt;BR /&gt;&amp;nbsp; %IF %sysfunc(upcase(&amp;amp;DOMAIN.))=LB %THEN %DO;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LENGTH PARCAT1 $50; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PARCAT1 = STRIP(&amp;amp;DOMAIN.CAT);&lt;BR /&gt;&amp;nbsp; %END;&lt;BR /&gt;%MEND MyMacro;&lt;/P&gt;&lt;P&gt;Data abc;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %MyMacro(Domain=LB);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However I agree with Astounding what do you want the code to look like, maybe post the whole section of code so we can see context for this.&amp;nbsp; Assuming it is SDTM why would you want to strip only if domain is LB?&amp;nbsp; Why also would parcat1 only be assigned a length is domain=lb?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Aug 2014 13:46:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150875#M29745</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-08-06T13:46:53Z</dc:date>
    </item>
    <item>
      <title>Re: Transfer two letters to Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150876#M29746</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, RW9.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my working code.&amp;nbsp; I want to resolve two non-professional part:&lt;/P&gt;&lt;P&gt;1. Pass 'LB' in better way.&lt;/P&gt;&lt;P&gt;2. If Domain ne 'LB', I won't generate PARCAT1. (For example, in VS domain, I do not need PARCAT1 variable)&lt;/P&gt;&lt;P&gt;===============&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%MACRO BASEANVARS(DOMAIN=);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; IF CMISS(&amp;amp;DOMAIN)=1 THEN DO; &lt;/P&gt;&lt;P&gt;&amp;nbsp; PUT "NOTE: YOU NEED TO SPECIFY TWO-CHAR DOMAIN NAME. NO VARIABLES GENERATED!";&lt;/P&gt;&lt;P&gt;&amp;nbsp; STOP ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; END;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; LENGTH PARAM AVALC $200 PARAMCD $8;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; IF STRIP(&amp;amp;DOMAIN.STRESU) = '' THEN PARAM = STRIP(COMPBL(&amp;amp;DOMAIN.TEST));&lt;/P&gt;&lt;P&gt;&amp;nbsp; ELSE PARAM = CATT(STRIP(COMPBL(&amp;amp;DOMAIN.TEST)),' (', STRIP(&amp;amp;DOMAIN.STRESU),')');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; IF CMISS(&amp;amp;DOMAIN.TESTCD)=0 THEN PARAMCD=STRIP(&amp;amp;DOMAIN.TESTCD);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; IF UPCASE(STRIP(&amp;amp;DOMAIN))='LB' THEN DO;&lt;/P&gt;&lt;P&gt;&amp;nbsp; LENGTH PARCAT1 $50; &lt;/P&gt;&lt;P&gt;&amp;nbsp; PARCAT1 = STRIP(&amp;amp;DOMAIN.CAT);&lt;/P&gt;&lt;P&gt;&amp;nbsp; END;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; *Analysis Values;&lt;/P&gt;&lt;P&gt;&amp;nbsp; AVAL&amp;nbsp; = &amp;amp;DOMAIN.STRESN;&lt;/P&gt;&lt;P&gt;&amp;nbsp; AVALC = STRIP(&amp;amp;DOMAIN.STRESC);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; IF CMISS(&amp;amp;DOMAIN.DTC)=0 THEN DO; %ISOtoDTM2(ISODTC=&amp;amp;DOMAIN.DTC, ADate=ADT, ATime=ATM, Rule=0); END;&lt;/P&gt;&lt;P&gt;&amp;nbsp; IF CMISS(ADT, TRTSDT) = 0 THEN ADY = ADT - TRTSDT + (ADT &amp;gt;= TRTSDT);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%MEND BASEANVARS;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA _LB_1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; MERGE ADSL _LB_S;&lt;/P&gt;&lt;P&gt;&amp;nbsp; BY USUBJID;&lt;/P&gt;&lt;P&gt;&amp;nbsp; IF STRIP(UPCASE(LBSTAT)) = 'NOT DONE' THEN DELETE;&lt;/P&gt;&lt;P&gt;&amp;nbsp; FORMAT ADT DATE9. ATM TIME5.;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; LENGTH LB $2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; LB='LB';&lt;/P&gt;&lt;P&gt;&amp;nbsp; %BASEANVARS(DOMAIN=LB);&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;======================&lt;/P&gt;&lt;P&gt;I guess in data step, I can not use %if ... %then...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Aug 2014 14:24:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150876#M29746</guid>
      <dc:creator>Abdu</dc:creator>
      <dc:date>2014-08-06T14:24:44Z</dc:date>
    </item>
    <item>
      <title>Re: Transfer two letters to Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150877#M29747</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So your creating Adam's based of the base dataset model.&amp;nbsp; Mmm, gotta say this wouldn't be my way of doing it.&amp;nbsp; I would create the spec first, generally in Excel so one tab per domain with variables formats etc.&amp;nbsp; Then I read this in and generate the program from there.&amp;nbsp; With that there is no need to decide what variables are present, or the other various conditionals.&amp;nbsp; At the end of the day if you have well presented specs, which are approved by the team, the actual coding is negligible (ok, maybe some of the mappings can get a bit complicated).&amp;nbsp; I did some months back demonstrate a system where metadata is stored in Excel in spec format so reviewable.&amp;nbsp; With this and a generic code generator was able to create RAW-&amp;gt;SDTM-&amp;gt;ADAM-&amp;gt;TLF Datasets-&amp;gt;Output with no actual coding whatsoever.&amp;nbsp; Just a generic loop over metadata.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Aug 2014 14:52:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150877#M29747</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-08-06T14:52:03Z</dc:date>
    </item>
    <item>
      <title>Re: Transfer two letters to Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150878#M29748</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Assuming you keep this approach in place, definitely expect to call the macro using DOMAIN=LB ... no quotes needed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here are a few suggestions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A better test for a two-character value would be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if length("&amp;amp;domain") ne 2 then do;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Checking for missing values does not require the STRIP function.&amp;nbsp; A simpler version:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if &amp;amp;domain.stresu = ' ' then param= ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The LENGTH statement cannot be executed conditionally.&amp;nbsp; If it appears in the program, you will always be open to getting messages about a variable being uninitialized.&amp;nbsp; So you can use macro language to control whether or not your DATA step will contain a LENGTH statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%if &amp;amp;domain=LB %then %do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; ... as detailed in earlier post;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You cannot use %IF/%THEN as statements that execute within a DATA step.&amp;nbsp; But you can certainly use %IF/%THEN as statements to control whether or not certain statements will be generated as part of the DATA step.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Finally (if appropriate for this application) most comparisons will not need a STRIP function.&amp;nbsp; Unless you have leading blanks in some character strings, STRIP is hardly ever needed.&amp;nbsp; SAS knows how to handle trailing blanks when making a comparison of character strings without the need for functions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Aug 2014 15:08:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150878#M29748</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-08-06T15:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: Transfer two letters to Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150879#M29749</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for sharing your idea and way to do it.&amp;nbsp; My thinking is, the specs are different depends on study and statistician.&amp;nbsp;&amp;nbsp; So that is why I made my Macro very small, part by part.&amp;nbsp; Many variables specs are same.&amp;nbsp; For the differences, I just need to modify my mall part.&amp;nbsp; It is easy to apply and maintain.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My Question is still there: How do I pass DAMAIN=LB to macro?&amp;nbsp; If I do not define LB as a variable in data step, that will give me a LB uninitialized warning.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks, &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Aug 2014 15:31:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150879#M29749</guid>
      <dc:creator>Abdu</dc:creator>
      <dc:date>2014-08-06T15:31:15Z</dc:date>
    </item>
    <item>
      <title>Re: Transfer two letters to Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150880#M29750</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;"Assuming you keep this approach in place, definitely expect to call the macro using DOMAIN=LB ... no quotes needed."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Then if I do not apply: LENGTH LB $2;&amp;nbsp; LB='LB'; before %BASEANVARS(DOMAIN=LB); I will get "Variable LB is uninitialized" warning.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Aug 2014 15:36:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150880#M29750</guid>
      <dc:creator>Abdu</dc:creator>
      <dc:date>2014-08-06T15:36:06Z</dc:date>
    </item>
    <item>
      <title>Re: Transfer two letters to Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150881#M29751</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You call the macro in this fashion:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%mymacro (domain=LB)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From that point, it is up to you to verify that the DATA step code does not mention a variable named LB.&amp;nbsp; It is only the generated DATA step code that determines whether a variable LB gets created (whether initialized or uninitialized).&amp;nbsp; So if your generated DATA step code contains a statement like this, you may get such a message:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;newvar = LB;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You have to control the generated DATA step code so that it has the correct syntax and only creates the needed variables.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Aug 2014 15:37:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150881#M29751</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-08-06T15:37:31Z</dc:date>
    </item>
    <item>
      <title>Re: Transfer two letters to Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150882#M29752</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When writing a macro you need to take care what are decisions that the macro needs to make (macro logic) and what just statements that the macro logic needs to generate. In general you should not include quotes around your parameter values and instead add quotes where needed in any SAS code that the macro generates.&amp;nbsp; In this case there is no need for quotes as you are not testing the macro parameter value against the value of any SAS data variable.&amp;nbsp; Instead you are using the value as part of a variable name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So your original macro could be re-written as below.&amp;nbsp; &lt;/P&gt;&lt;P&gt;The effect is that the new variable PARCAT1 is defined and assigned a value only when DOMAIN is LB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;%macro&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; mymacro(domain);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%if&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%upcase&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;(&amp;amp;domain)=LB &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%then&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%do&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; length parcat1 $&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;50&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; parcat1 = &amp;amp;domain.cat;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%end&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;%mend&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; mymacro;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Aug 2014 15:53:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150882#M29752</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-08-06T15:53:26Z</dc:date>
    </item>
    <item>
      <title>Re: Transfer two letters to Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150883#M29753</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Abdu,&lt;/P&gt;&lt;P&gt;As a member of a SAS team and a trainer of novice SAS programmers, I want to take Tom's statement one step further.&amp;nbsp; Your coding style can be difficult to maintain as proven by all the comments to your post.&amp;nbsp; May I invite you to look through the community and find examples of call symputs that call macros based on values in a dataset and data _null_ statements that build entire processing flows (data and sql).&amp;nbsp; I am observing that your style is mixing two styles of programming. A data step that calls a macro and a macro that contains code used in a datastep.&amp;nbsp; My own style and preference is to build a macro that builds code and then call the macro.&amp;nbsp;&amp;nbsp; For example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(This is untested code for example purposes only.&amp;nbsp; The syntax has not been verified)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%global domain;&lt;/P&gt;&lt;P&gt;%MACRO MyMacro(Domain=);&lt;/P&gt;&lt;P&gt;DATA _LB_1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; MERGE ADSL _LB_S;&lt;/P&gt;&lt;P&gt;&amp;nbsp; BY USUBJID;&lt;/P&gt;&lt;P&gt;&amp;nbsp; IF STRIP(UPCASE(LBSTAT)) = 'NOT DONE' THEN DELETE;&lt;/P&gt;&lt;P&gt;&amp;nbsp; FORMAT ADT DATE9. ATM TIME5.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %if %UPCASE(&amp;amp;DOMAIN.))=LB %THEN %DO;&lt;/P&gt;&lt;P&gt;&amp;nbsp; LENGTH PARCAT1 $50; &lt;/P&gt;&lt;P&gt;&amp;nbsp; PARCAT1 = &amp;amp;DOMAIN.CAT;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* assume LBCAT is a variable in one of the merged datasets */&lt;/P&gt;&lt;P&gt; %end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; RUN;&lt;/P&gt;&lt;P&gt;%MEND MyMacro;&lt;/P&gt;&lt;P&gt;%MyMacro(domain=LB);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Aug 2014 16:27:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150883#M29753</guid>
      <dc:creator>jwillis</dc:creator>
      <dc:date>2014-08-06T16:27:01Z</dc:date>
    </item>
    <item>
      <title>Re: Transfer two letters to Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150884#M29754</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, Tom.&lt;/P&gt;&lt;P&gt;Maybe I was not very clear.&amp;nbsp; Actually, I does not have a variable have value 'LB'.&amp;nbsp; My question is just a technique question.&amp;nbsp; How can I pass 'LB' to macro without putting 'LB' to a variable then pass the variable to macro parameter domain.&amp;nbsp; In my previous response, my working macro is generate a variable then pass it to macro parameter.&amp;nbsp; I was trying to find a easier way.&amp;nbsp; I do have two solutions:&lt;/P&gt;&lt;P&gt;1. As you said and applied in my previous code, I named a variable LB that have value 'LB'.&lt;/P&gt;&lt;P&gt;2. Create a independent macro, that as JW suggested.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much, SAS community.&amp;nbsp; I am improving by all of your comments.&lt;/P&gt;&lt;P&gt;Abdu.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Aug 2014 18:32:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150884#M29754</guid>
      <dc:creator>Abdu</dc:creator>
      <dc:date>2014-08-06T18:32:07Z</dc:date>
    </item>
    <item>
      <title>Re: Transfer two letters to Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150885#M29755</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In normal SAS statements you need to put quotes around literal values so that it knows you do not mean a variable name or other language token. In general to a macro quotes are just like any other character. So if you want to call the macro with the value of LB then that is what you would do. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt; set have;&lt;/P&gt;&lt;P&gt;%mymacro(LB);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Aug 2014 18:43:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transfer-two-letters-to-Macro/m-p/150885#M29755</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-08-06T18:43:15Z</dc:date>
    </item>
  </channel>
</rss>

