<?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: datastep error due to macro / correction needed in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/datastep-error-due-to-macro-correction-needed/m-p/722100#M27866</link>
    <description>&lt;P&gt;I actually solved the problem writing this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;* Jahr1 = aktuelles Jahr, Jahr2 = Vorjahr ;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; Jahr1=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%eval&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(%year(&amp;amp;Auswertungstag.));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; Jahr2=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%eval&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;Jahr1.-1);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;Jahr1.;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;Jahr2.;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;I don't know if it's worse than the solutions you proposed.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 26 Feb 2021 11:09:14 GMT</pubDate>
    <dc:creator>PierreYvesILY</dc:creator>
    <dc:date>2021-02-26T11:09:14Z</dc:date>
    <item>
      <title>datastep error due to macro / correction needed</title>
      <link>https://communities.sas.com/t5/New-SAS-User/datastep-error-due-to-macro-correction-needed/m-p/722074#M27859</link>
      <description>&lt;P&gt;dear SAS experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this:&lt;/P&gt;&lt;P&gt;* Jahr1 = aktuelles Jahr, Jahr2 = Vorjahr ;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; Jahr1=%year(&amp;amp;Auswertungstag.);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; Jahr2=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%eval&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;Jahr1.-1);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;Jahr1.;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;Jahr2.;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; ORB_Select_&amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;Jahr2.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; MUC_PROD.ORB_&amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;Jahr2.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;keep&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;= ZSRID ANZAHL MONAT KW PLATTFORM MBRBEZ_BT MARKTREGION_BT &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NLBEZ_BT MR_KOMPAKT_BT);&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;jahr=&amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;Jahr2.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; ORB_Select_&amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;Jahr1.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; MUC_PROD.ORB_&amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;Jahr1.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;keep&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;= ZSRID ANZAHL MONAT KW PLATTFORM MBRBEZ_BT MARKTREGION_BT &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NLBEZ_BT MR_KOMPAKT_BT);&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;jahr=&amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;Jahr1.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get the following errors:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;25 GOPTIONS ACCESSIBLE;&lt;/P&gt;&lt;P&gt;26 data ORB_Select_&amp;amp;Jahr2.;&lt;/P&gt;&lt;P&gt;27 set MUC_PROD.ORB_&amp;amp;Jahr2. (keep= ZSRID ANZAHL MONAT KW PLATTFORM MBRBEZ_BT MARKTREGION_BT&lt;/P&gt;&lt;P&gt;28 NLBEZ_BT MR_KOMPAKT_BT);&lt;/P&gt;&lt;P&gt;29 jahr=&amp;amp;Jahr2.;&lt;/P&gt;&lt;P&gt;30 run;&lt;/P&gt;&lt;P&gt;NOTE: There were 410737 observations read from the data set MUC_PROD.ORB_2020.&lt;/P&gt;&lt;P&gt;NOTE: The data set WORK.ORB_SELECT_2020 has 410737 observations and 10 variables.&lt;/P&gt;&lt;P&gt;NOTE: Compressing data set WORK.ORB_SELECT_2020 decreased size by 42.23 percent.&lt;/P&gt;&lt;P&gt;Compressed is 669 pages; un-compressed would require 1158 pages.&lt;/P&gt;&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;P&gt;real time 1.74 seconds&lt;/P&gt;&lt;P&gt;cpu time 0.75 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;31 data ORB_Select_&amp;amp;Jahr1.;&lt;/P&gt;&lt;P&gt;NOTE: Line generated by the macro variable "JAHR1".&lt;/P&gt;&lt;P&gt;31 ORB_Select_2021&lt;/P&gt;&lt;P&gt;____&lt;/P&gt;&lt;P&gt;22&lt;/P&gt;&lt;P&gt;____&lt;/P&gt;&lt;P&gt;200&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, /, ;, _DATA_, _LAST_, _NULL_.&lt;/P&gt;&lt;P&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/P&gt;&lt;P&gt;32 set MUC_PROD.ORB_&amp;amp;Jahr1. (keep= ZSRID ANZAHL MONAT KW PLATTFORM MBRBEZ_BT MARKTREGION_BT&lt;/P&gt;&lt;P&gt;NOTE: Line generated by the macro variable "JAHR1".&lt;/P&gt;&lt;P&gt;32 MUC_PROD.ORB_2021&lt;/P&gt;&lt;P&gt;____&lt;/P&gt;&lt;P&gt;22&lt;/P&gt;&lt;P&gt;____&lt;/P&gt;&lt;P&gt;2 The SAS System 09:12 Friday, February 26, 2021&lt;/P&gt;&lt;P&gt;200&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, -, :, ;, CUROBS, END, INDSNAME, KEY,&lt;/P&gt;&lt;P&gt;KEYRESET, KEYS, NOBS, OPEN, POINT, _DATA_, _LAST_, _NULL_.&lt;/P&gt;&lt;P&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/P&gt;&lt;P&gt;33 NLBEZ_BT MR_KOMPAKT_BT);&lt;/P&gt;&lt;P&gt;ERROR: File MUC_PROD.ORB_.DATA does not exist.&lt;/P&gt;&lt;P&gt;ERROR: The metadata for the table/view MUC_PROD.ORB_ does not exist.&lt;/P&gt;&lt;P&gt;34 jahr=&amp;amp;Jahr1.;&lt;/P&gt;&lt;P&gt;35 run;&lt;/P&gt;&lt;P&gt;NOTE: Compression was disabled for data set WORK.ORB_SELECT_ because compression overhead would increase the size of the data set.&lt;/P&gt;&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/P&gt;&lt;P&gt;WARNING: The data set WORK.ORB_SELECT_ may be incomplete. When this step was stopped there were 0 observations and 1 variables.&lt;/P&gt;&lt;P&gt;WARNING: Data set WORK.ORB_SELECT_ was not replaced because this step was stopped.&lt;/P&gt;&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;P&gt;real time 0.00 seconds&lt;/P&gt;&lt;P&gt;cpu time 0.00 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't understand what's wrong, as the datastep text is exactly the same and works for the first one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I correct this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thx in advance&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;PY&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Feb 2021 08:57:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/datastep-error-due-to-macro-correction-needed/m-p/722074#M27859</guid>
      <dc:creator>PierreYvesILY</dc:creator>
      <dc:date>2021-02-26T08:57:06Z</dc:date>
    </item>
    <item>
      <title>Re: datastep error due to macro / correction needed</title>
      <link>https://communities.sas.com/t5/New-SAS-User/datastep-error-due-to-macro-correction-needed/m-p/722079#M27860</link>
      <description>&lt;P&gt;I assume&amp;nbsp;&lt;STRONG&gt;%year&lt;/STRONG&gt; is a predefined macro, unknown to me.&lt;/P&gt;
&lt;P&gt;What is the result of next test code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let Jahr1=%year(&amp;amp;Auswertungstag.);
%put *&amp;amp;Jahr1*&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;are there blanks or special characters in the PUT result?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Feb 2021 09:52:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/datastep-error-due-to-macro-correction-needed/m-p/722079#M27860</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2021-02-26T09:52:06Z</dc:date>
    </item>
    <item>
      <title>Re: datastep error due to macro / correction needed</title>
      <link>https://communities.sas.com/t5/New-SAS-User/datastep-error-due-to-macro-correction-needed/m-p/722088#M27863</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/281554"&gt;@PierreYvesILY&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To me this looks like a macro quoting issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Change the definition of macro variable &lt;FONT face="courier new,courier"&gt;Jahr1&lt;/FONT&gt; to&lt;/P&gt;
&lt;PRE&gt;&lt;FONT size="4"&gt;%let Jahr1=&lt;STRONG&gt;&lt;FONT color="#00CCFF"&gt;%unquote(&lt;/FONT&gt;&lt;/STRONG&gt;%year(&amp;amp;Auswertungstag.)&lt;STRONG&gt;&lt;FONT color="#00CCFF"&gt;)&lt;/FONT&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Feb 2021 10:26:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/datastep-error-due-to-macro-correction-needed/m-p/722088#M27863</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-02-26T10:26:16Z</dc:date>
    </item>
    <item>
      <title>Re: datastep error due to macro / correction needed</title>
      <link>https://communities.sas.com/t5/New-SAS-User/datastep-error-due-to-macro-correction-needed/m-p/722089#M27864</link>
      <description>&lt;P&gt;%YEAR is not a standard SAS macro function, so it is of interest to see the code of that macro.&lt;/P&gt;
&lt;P&gt;But why don't you use the SAS function (assuming AUSWERTUNGSTAG contains a SAS date value)?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let auswertungstag=%sysfunc(today());
%let jahr1=%sysfunc(year(&amp;amp;auswertungstag.));
%put &amp;amp;=jahr1.;

data ORB_Select_&amp;amp;Jahr1.;
set sashelp.class;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;PRE&gt; 73         %let auswertungstag=%sysfunc(today());
 74         %let jahr1=%sysfunc(year(&amp;amp;auswertungstag.));
 75         %put &amp;amp;=jahr1.;
 JAHR1=2021
 76         
 77         data ORB_Select_&amp;amp;Jahr1.;
 78         set sashelp.class;
 79         run;
 
 NOTE: There were 19 observations read from the data set SASHELP.CLASS.
 NOTE: The data set WORK.ORB_SELECT_2021 has 19 observations and 5 variables.
 NOTE:  Verwendet wurde: DATA statement - (Gesamtverarbeitungszeit):
       real time           0.01 seconds
       cpu time            0.01 seconds&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Feb 2021 10:32:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/datastep-error-due-to-macro-correction-needed/m-p/722089#M27864</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-02-26T10:32:04Z</dc:date>
    </item>
    <item>
      <title>Re: datastep error due to macro / correction needed</title>
      <link>https://communities.sas.com/t5/New-SAS-User/datastep-error-due-to-macro-correction-needed/m-p/722100#M27866</link>
      <description>&lt;P&gt;I actually solved the problem writing this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;* Jahr1 = aktuelles Jahr, Jahr2 = Vorjahr ;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; Jahr1=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%eval&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(%year(&amp;amp;Auswertungstag.));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; Jahr2=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%eval&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;Jahr1.-1);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;Jahr1.;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;Jahr2.;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;I don't know if it's worse than the solutions you proposed.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Feb 2021 11:09:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/datastep-error-due-to-macro-correction-needed/m-p/722100#M27866</guid>
      <dc:creator>PierreYvesILY</dc:creator>
      <dc:date>2021-02-26T11:09:14Z</dc:date>
    </item>
    <item>
      <title>Re: datastep error due to macro / correction needed</title>
      <link>https://communities.sas.com/t5/New-SAS-User/datastep-error-due-to-macro-correction-needed/m-p/722103#M27867</link>
      <description>&lt;P&gt;If the %YEAR macro does nothing else than the data step YEAR function, then I would (for reasons of maintainability) always use the data step function with %sysfunc.&lt;/P&gt;
&lt;P&gt;The same holds true for every case where there already is a SAS function available.&lt;/P&gt;
&lt;P&gt;And IF you absolutely want to shorten your typing, the %YEAR macro should be defined like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let auswertungstag = %sysfunc(today());

%macro year(datum);
%sysfunc(year(&amp;amp;datum.));
%mend;

%let jahr1 = %year(&amp;amp;auswertungstag.);

data test&amp;amp;jahr1.;
set sashelp.class;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;No fancy processing, no quoting.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Feb 2021 11:18:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/datastep-error-due-to-macro-correction-needed/m-p/722103#M27867</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-02-26T11:18:54Z</dc:date>
    </item>
  </channel>
</rss>

