<?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: Issue using SYMGET inside a macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Issue-using-SYMGET-inside-a-macro/m-p/22510#M3644</link>
    <description>It's best to start with a more basic DATA step execution to exercise your DATA step (and / or PROC steps too) logic.  Then look at how you can inject macro language constructs for more flexibility.&lt;BR /&gt;
&lt;BR /&gt;
Firstly, I see a DATA _NULL_  statement followed directly by an assignment that uses the INPUT function, however there would be no variable value assigned.  I suspect that you thought that you could use a mix of SYMPUT and SYMGET within the same DATA step, then inserted the DATA _NULL_ when it didn't work for you.&lt;BR /&gt;
&lt;BR /&gt;
Basically there are fundamental issues with your technique - one that attempts to mix macro language (a compilation time event) and DATA step processing.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
SAS Macro Language: Reference, DATA Step Functions for Macros&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/a003167025.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/a003167025.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Intermediate and Advanced SAS® Macros&lt;BR /&gt;
Steven First, Katie Ronk, Systems Seminar Consultants, Madison, WI&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi31/107-31.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi31/107-31.pdf&lt;/A&gt;</description>
    <pubDate>Thu, 26 Nov 2009 14:47:01 GMT</pubDate>
    <dc:creator>sbb</dc:creator>
    <dc:date>2009-11-26T14:47:01Z</dc:date>
    <item>
      <title>Issue using SYMGET inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-using-SYMGET-inside-a-macro/m-p/22508#M3642</link>
      <description>Hello,&lt;BR /&gt;
I call a first macro to calculate &amp;amp;type.&lt;BR /&gt;
&lt;BR /&gt;
Then I would like to update a field of a table from the macro; I try to use SYMGET to do it.&lt;BR /&gt;
&lt;BR /&gt;
data out;&lt;BR /&gt;
set In;&lt;BR /&gt;
	%TestsFormat(code, 'NUM', '1','3', code_);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
%Macro TestsFormat(MyVarIn, MyType, MyValueOk, MyValueNok, MyVarOut) / store;&lt;BR /&gt;
	%verif_num_char_date(&amp;amp;MyVarIn);&lt;BR /&gt;
	%If &amp;amp;type ne &amp;amp;MyType %Then &amp;amp;MyVarOut=symget("MyValueNok"); %Else &amp;amp;MyVarOut=symget("MyValueOk");&lt;BR /&gt;
%Mend;&lt;BR /&gt;
&lt;BR /&gt;
%macro verif_num_char_date(MyVar) / store;&lt;BR /&gt;
	%global type;&lt;BR /&gt;
	DATA _NULL_;&lt;BR /&gt;
		var=input("&amp;amp;MyVar" ,?? COMMA8.);&lt;BR /&gt;
		IF var ne . then call symput('type','NUM');&lt;BR /&gt;
		ELSE do;&lt;BR /&gt;
			var=input("&amp;amp;MyVar",ANYDTDTM.);&lt;BR /&gt;
			if var ne . then call symput('type','DAT');&lt;BR /&gt;
			else call symput('type','CHAR');&lt;BR /&gt;
		end;&lt;BR /&gt;
    run;&lt;BR /&gt;
%mend;&lt;BR /&gt;
&lt;BR /&gt;
I have the following Error message :&lt;BR /&gt;
&lt;BR /&gt;
NOTE: Generated line by the macro variable "MYVAROUT".&lt;BR /&gt;
1       code_&lt;BR /&gt;
        -----&lt;BR /&gt;
        180&lt;BR /&gt;
&lt;BR /&gt;
ERROR 180-322: Incorrect Instruction&lt;BR /&gt;
&lt;BR /&gt;
If someone has an idea, it would be great.&lt;BR /&gt;
&lt;BR /&gt;
Thanks.

Message was edited by: phil27</description>
      <pubDate>Thu, 26 Nov 2009 12:25:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-using-SYMGET-inside-a-macro/m-p/22508#M3642</guid>
      <dc:creator>phil27</dc:creator>
      <dc:date>2009-11-26T12:25:14Z</dc:date>
    </item>
    <item>
      <title>Re: Issue using SYMGET inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-using-SYMGET-inside-a-macro/m-p/22509#M3643</link>
      <description>I think the problem is here:&lt;BR /&gt;
your macro creates something like this statemets:&lt;BR /&gt;
&lt;BR /&gt;
data out;&lt;BR /&gt;
set In;&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
/* your code */ &lt;BR /&gt;
run;&lt;BR /&gt;
code_ = &lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
you can use options mprint; to see what your macro creates</description>
      <pubDate>Thu, 26 Nov 2009 13:37:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-using-SYMGET-inside-a-macro/m-p/22509#M3643</guid>
      <dc:creator>SAS_user</dc:creator>
      <dc:date>2009-11-26T13:37:31Z</dc:date>
    </item>
    <item>
      <title>Re: Issue using SYMGET inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-using-SYMGET-inside-a-macro/m-p/22510#M3644</link>
      <description>It's best to start with a more basic DATA step execution to exercise your DATA step (and / or PROC steps too) logic.  Then look at how you can inject macro language constructs for more flexibility.&lt;BR /&gt;
&lt;BR /&gt;
Firstly, I see a DATA _NULL_  statement followed directly by an assignment that uses the INPUT function, however there would be no variable value assigned.  I suspect that you thought that you could use a mix of SYMPUT and SYMGET within the same DATA step, then inserted the DATA _NULL_ when it didn't work for you.&lt;BR /&gt;
&lt;BR /&gt;
Basically there are fundamental issues with your technique - one that attempts to mix macro language (a compilation time event) and DATA step processing.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
SAS Macro Language: Reference, DATA Step Functions for Macros&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/a003167025.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/a003167025.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Intermediate and Advanced SAS® Macros&lt;BR /&gt;
Steven First, Katie Ronk, Systems Seminar Consultants, Madison, WI&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi31/107-31.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi31/107-31.pdf&lt;/A&gt;</description>
      <pubDate>Thu, 26 Nov 2009 14:47:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-using-SYMGET-inside-a-macro/m-p/22510#M3644</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-11-26T14:47:01Z</dc:date>
    </item>
    <item>
      <title>Re: Issue using SYMGET inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-using-SYMGET-inside-a-macro/m-p/22511#M3645</link>
      <description>As said above, many problems with your code.&lt;BR /&gt;
You need to get up to speed with the macro language, and might want to consider proper training.&lt;BR /&gt;
In this case, think of the macro language as a code generator.&lt;BR /&gt;
&lt;BR /&gt;
This will work:&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
%Macro TestsFormat(MyVarIn, MyType, MyValueOk, MyValueNok, MyVarOut);&lt;BR /&gt;
  VAR=input(&amp;amp;MyVarIn ,?? COMMA8.);&lt;BR /&gt;
  if VAR ne . then TYPE='NUM';&lt;BR /&gt;
  else do;&lt;BR /&gt;
    VAR=input(&amp;amp;MyVarIn,?? ANYDTDTM.);&lt;BR /&gt;
    TYPE=ifc( VAR ne . , 'DAT', 'CHAR');&lt;BR /&gt;
  end;&lt;BR /&gt;
  &amp;amp;MyVarOut=ifc(TYPE = &amp;amp;MyType, &amp;amp;MyValueOk, &amp;amp;MyValueNok);&lt;BR /&gt;
%Mend;&lt;BR /&gt;
[/pre][pre]&lt;BR /&gt;
&lt;BR /&gt;
data OUT;&lt;BR /&gt;
  set SASHELP.CLASS;&lt;BR /&gt;
   AGEC=put(age,3.);&lt;BR /&gt;
  %TestsFormat(AGEC, 'NUM', '1','3', code_);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Note that a date like 20091231 will end up as NUM here.</description>
      <pubDate>Thu, 26 Nov 2009 22:16:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-using-SYMGET-inside-a-macro/m-p/22511#M3645</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2009-11-26T22:16:47Z</dc:date>
    </item>
  </channel>
</rss>

