<?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: Understanding SYMPUT and Similar Routines in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Understanding-SYMPUT-and-Similar-Routines/m-p/277308#M19176</link>
    <description>&lt;P&gt;The only function you need to know in order to write your own SAS code is SYMPUTX. The other functions will help you understand older SAS code.&lt;/P&gt;</description>
    <pubDate>Tue, 14 Jun 2016 17:21:47 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2016-06-14T17:21:47Z</dc:date>
    <item>
      <title>Understanding SYMPUT and Similar Routines</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Understanding-SYMPUT-and-Similar-Routines/m-p/277297#M19174</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi, Folks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm&amp;nbsp;very new to SAS and am having a bit of trouble understanding the differences between&amp;nbsp;SYMPUT, SYMPUTX, SYMPUTN,&amp;nbsp;and SYMGET. I recognize that they all have a relationship to invoking macros but I'm not sure when each is appropriate. Could a more experienced user explain to me how these four functions overlap and how to determine which is most efficient?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Included below is some sample code from a program I am trying to interpret as part of a learning exercise. In this specific context, I'm wondering why SYMPUT would be used&amp;nbsp; instead of the other options listed above.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; year = year(date());&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp; prev_year=year(date()) -&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp; call symput(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'year'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;, year); &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp; call symput(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'prev_year'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;, prev_year); &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jun 2016 16:50:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Understanding-SYMPUT-and-Similar-Routines/m-p/277297#M19174</guid>
      <dc:creator>tbesser</dc:creator>
      <dc:date>2016-06-14T16:50:16Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding SYMPUT and Similar Routines</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Understanding-SYMPUT-and-Similar-Routines/m-p/277303#M19175</link>
      <description>&lt;P&gt;symput creates a macro variable, Symputx does so but removes leading and trailing spaces. Note that when use a numeric in Symput Symputx without explicitly converting to string using a format that the result is created with a default format that may include blanks.&lt;/P&gt;
&lt;P&gt;SymputN is intended for use with SCL programming only as far as I can determine. Some of the SCL functions work in&amp;nbsp;Base&amp;nbsp;SAS but I get&amp;nbsp;an error with symputn.&lt;/P&gt;
&lt;P&gt;And&amp;nbsp;macros only generate code text.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please examine the log from this code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  year = year(date());
  prev_year=year(date()) -1;
  call symput('year', year); 
  call symputx('prev_year', prev_year); 
run;
%put "&amp;amp;year"  "&amp;amp;prev_year";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note the spaces before 2016 (year) inside the quotes but not with 2015 (prev_year).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SYMGET is to return the value of a macro variable. There can be some slightly esoteric differences about what happens when using&lt;/P&gt;
&lt;P&gt;var= symget('year')&lt;/P&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;Var= &amp;amp;year&lt;/P&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;Var="&amp;amp;year"&lt;/P&gt;
&lt;P&gt;The main difference is that without quotes you can reference the name of datastep variable that contains names of macro variables and Symget will resolve the requested macro variable but the literal use when reference with an &amp;amp; you do not have that flexibility.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One reason SYMPUT may be used instead of others is that the Symputx and Symputn are relatively new and the code you look at may be "old". Second is habit for programmers that learned Symput when that was the only option. Third would be when you do not want to use the feature of Symputx to remove leading and trailing blanks because you need those blanks for some later purpose.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jun 2016 17:25:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Understanding-SYMPUT-and-Similar-Routines/m-p/277303#M19175</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-06-14T17:25:28Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding SYMPUT and Similar Routines</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Understanding-SYMPUT-and-Similar-Routines/m-p/277308#M19176</link>
      <description>&lt;P&gt;The only function you need to know in order to write your own SAS code is SYMPUTX. The other functions will help you understand older SAS code.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jun 2016 17:21:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Understanding-SYMPUT-and-Similar-Routines/m-p/277308#M19176</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-06-14T17:21:47Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding SYMPUT and Similar Routines</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Understanding-SYMPUT-and-Similar-Routines/m-p/277310#M19177</link>
      <description>&lt;P&gt;Just to play devil's advocate for a moment ... if you are relatively new to SAS, you should not spend time on macro language.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Macro language does not process data.&amp;nbsp; Instead, it generates SAS statements, which will then process your data.&amp;nbsp; You need more experience with SAS statements, to be able to picture the statements that could be generated.&amp;nbsp; Only then will macro language be useful.&amp;nbsp; Here is a list of topics that would be more worthy of your time at this point:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;MERGE, and using in= variables to detect matches and mismatches&lt;/P&gt;
&lt;P&gt;BY statement in a DATA step&lt;/P&gt;
&lt;P&gt;How SAS handles dates&lt;/P&gt;
&lt;P&gt;RETAIN statement, and sum statement&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The list could be longer, but the real point is that many SAS language topics are more important than macro language when you are new to SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jun 2016 17:23:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Understanding-SYMPUT-and-Similar-Routines/m-p/277310#M19177</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-06-14T17:23:20Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding SYMPUT and Similar Routines</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Understanding-SYMPUT-and-Similar-Routines/m-p/277329#M19178</link>
      <description>&lt;P&gt;&lt;FONT color="#FF0000"&gt;SYM&lt;/FONT&gt;GET and &lt;FONT color="#FF0000"&gt;SYM&lt;/FONT&gt;GETN are used to retrieve the value of a macro variable during execution of a data step. &amp;nbsp;The N version returns a numeric value by converting the character macro variable value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jun 2016 18:06:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Understanding-SYMPUT-and-Similar-Routines/m-p/277329#M19178</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-06-14T18:06:48Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding SYMPUT and Similar Routines</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Understanding-SYMPUT-and-Similar-Routines/m-p/277600#M19208</link>
      <description>&lt;P&gt;ballardw: Thank you for your response! It was particularly helpful to know that Symputn and Symputx are relatively new - this does explain why the code I was trying to understand would have used symput!&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2016 15:32:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Understanding-SYMPUT-and-Similar-Routines/m-p/277600#M19208</guid>
      <dc:creator>tbesser</dc:creator>
      <dc:date>2016-06-15T15:32:20Z</dc:date>
    </item>
  </channel>
</rss>

