<?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: Pass a the value of VTYPE to macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Pass-a-the-value-of-VTYPE-to-macro-variable/m-p/162852#M31557</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Adding to what &lt;A __default_attr="255172" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt; posted:&lt;/P&gt;&lt;P&gt;You will need to read up a bit of how SAS macro language and SAS data step interact. You have a timing issue with your %let statement and it executes before the data step actually iterates through the data.&lt;/P&gt;&lt;P&gt;Using a "call symput" instead will do the job - only execute it once though "IF _n_=1 and VTYPE(ENRLL)= 'C' THEN DO;"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;&amp;nbsp; set sashelp.class;&lt;BR /&gt;&amp;nbsp; length vartyp2 $1;&lt;BR /&gt;&amp;nbsp; retain vartyp2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if _n_=1 and vtype(name)= 'c' then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vartyp2 = vtype(name);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput ('vartype', vtype(name));&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%put vartype is: &amp;amp;vartype;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 17 May 2014 00:37:59 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2014-05-17T00:37:59Z</dc:date>
    <item>
      <title>Pass a the value of VTYPE to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-a-the-value-of-VTYPE-to-macro-variable/m-p/162850#M31555</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 am trying to pass the return value of VTYPE to a macro variable, but was not successful.&amp;nbsp; The code and output are as the following.&amp;nbsp; Please give a suggestion:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CODE:&lt;/P&gt;&lt;P&gt;DATA test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; SET LOCFRST;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; IF VTYPE(ENRLL)= 'C' THEN DO;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %LET VarTyp=VTYPE(ENRLL);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VarTyp2 = VTYPE(ENRLL);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PUT "NOTE: VTYPE = &amp;amp;VarTyp = VTYPE(ENRLL), Another test: " VarTyp2=;&lt;/P&gt;&lt;P&gt;&amp;nbsp; END;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOG:&lt;/P&gt;&lt;P&gt;NOTE: VTYPE = VTYPE(ENRLL) = VTYPE(ENRLL), Another test: VarTyp2=C&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Why the 'C' did not assign to Macrovariable VarTyp?&lt;/P&gt;&lt;P&gt;&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>Fri, 16 May 2014 20:48:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-a-the-value-of-VTYPE-to-macro-variable/m-p/162850#M31555</guid>
      <dc:creator>Abdu</dc:creator>
      <dc:date>2014-05-16T20:48:02Z</dc:date>
    </item>
    <item>
      <title>Re: Pass a the value of VTYPE to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-a-the-value-of-VTYPE-to-macro-variable/m-p/162851#M31556</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In a data step it's easier to use call symput to create macro variables. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following should work. &lt;/P&gt;&lt;P&gt;call symput ('vartype', vtype(enrll));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How does the macro language know if you want to store the text "VTYPE(ENRLL)" or the resolved value of said function?&lt;/P&gt;&lt;P&gt;You can tell it to resolve the function using %sysfunc, %eval depending on what you're doing.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 May 2014 20:55:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-a-the-value-of-VTYPE-to-macro-variable/m-p/162851#M31556</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-05-16T20:55:05Z</dc:date>
    </item>
    <item>
      <title>Re: Pass a the value of VTYPE to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-a-the-value-of-VTYPE-to-macro-variable/m-p/162852#M31557</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Adding to what &lt;A __default_attr="255172" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt; posted:&lt;/P&gt;&lt;P&gt;You will need to read up a bit of how SAS macro language and SAS data step interact. You have a timing issue with your %let statement and it executes before the data step actually iterates through the data.&lt;/P&gt;&lt;P&gt;Using a "call symput" instead will do the job - only execute it once though "IF _n_=1 and VTYPE(ENRLL)= 'C' THEN DO;"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;&amp;nbsp; set sashelp.class;&lt;BR /&gt;&amp;nbsp; length vartyp2 $1;&lt;BR /&gt;&amp;nbsp; retain vartyp2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if _n_=1 and vtype(name)= 'c' then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vartyp2 = vtype(name);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput ('vartype', vtype(name));&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%put vartype is: &amp;amp;vartype;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 17 May 2014 00:37:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-a-the-value-of-VTYPE-to-macro-variable/m-p/162852#M31557</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2014-05-17T00:37:59Z</dc:date>
    </item>
  </channel>
</rss>

