<?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: error in a dataset with dates in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/error-in-a-dataset-with-dates/m-p/747316#M29479</link>
    <description>&lt;P&gt;You are expecting the &amp;amp;VKW_DrK will be available in the same DATA step that creates it.&amp;nbsp; But that's not true,&amp;nbsp; It's not available until after the RUN statement causes the DATA step to execute.&amp;nbsp; Luckily, you already have a DATA step variable you can use instead.&amp;nbsp; Change this code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call symput('VKW_DrK',VKW_DrK);
%put &amp;amp;VKW_DrK.;
call symputx ('Dateiname',cats('Dr_Klein_KW_Reporting_',Jahr,'_KW',&amp;amp;VKW_DrK.));
call symputx('Zeitraum', cats(Jahr,'_KW',&amp;amp;VKW_DrK.));
run;
%put &amp;amp;Dateiname. &amp;amp;Zeitraum.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Instead, use:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call symput('VKW_DrK',VKW_DrK);
call symputx ('Dateiname',cats('Dr_Klein_KW_Reporting_',Jahr,'_KW',VKW_DrK));
call symputx('Zeitraum', cats(Jahr,'_KW',VKW_DrK));
run;
%put &amp;amp;Dateiname. &amp;amp;Zeitraum.;
%put &amp;amp;VKW_Drk;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 11 Jun 2021 12:28:09 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2021-06-11T12:28:09Z</dc:date>
    <item>
      <title>error in a dataset with dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/error-in-a-dataset-with-dates/m-p/747314#M29478</link>
      <description>&lt;P&gt;dear SAS experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used the following code and get a bunch of errors:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%let Auswertungstag=%sysfunc(today());
*%let Auswertungstag = %sysevalf('01JAN2021'd);
%put &amp;amp;Auswertungstag.;

%let Jahr = %year(&amp;amp;Auswertungstag.);
%put &amp;amp;Jahr. ;

%let Monat = %month(&amp;amp;Auswertungstag.);
%put &amp;amp;Monat.;

data KW_DrK;
format VKW_DrK best2.;
Tag = %eval(&amp;amp;Auswertungstag.);
%kwdrk(&amp;amp;Auswertungstag.);
if KW_DrK = 1 	then VKW_DrK = 52;
				else VKW_DrK = KW_DrK - 1;
if VKW_DrK = 52 then Jahr = &amp;amp;Jahr.-1;
				else Jahr = &amp;amp;Jahr.; 
VKW_DrK = compress(VKW_DrK);
call symput('VKW_DrK',VKW_DrK);
%put &amp;amp;VKW_DrK.;
call symputx ('Dateiname',cats('Dr_Klein_KW_Reporting_',Jahr,'_KW',&amp;amp;VKW_DrK.));
call symputx('Zeitraum', cats(Jahr,'_KW',&amp;amp;VKW_DrK.));
run;
%put &amp;amp;Dateiname. &amp;amp;Zeitraum.;&lt;/PRE&gt;&lt;P&gt;here the logfile:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;592        %let Auswertungstag=%sysfunc(today());
593        *%let Auswertungstag = %sysevalf('01JAN2021'd);
594        %put &amp;amp;Auswertungstag.;
22442
595        
596        %let Jahr = %year(&amp;amp;Auswertungstag.);
597        %put &amp;amp;Jahr. ;
2021
598        
599        %let Monat = %month(&amp;amp;Auswertungstag.);
600        %put &amp;amp;Monat.;
6
601        
602        data KW_DrK;
603        format VKW_DrK best2.;
604        Tag = %eval(&amp;amp;Auswertungstag.);
605        %kwdrk(&amp;amp;Auswertungstag.);
606        if KW_DrK = 1 	then VKW_DrK = 52;
5                                                          The SAS System                                14:11 Friday, June 11, 2021

607        				else VKW_DrK = KW_DrK - 1;
608        if VKW_DrK = 52 then Jahr = &amp;amp;Jahr.-1;
609        				else Jahr = &amp;amp;Jahr.;
610        VKW_DrK = compress(VKW_DrK);
611        call symput('VKW_DrK',VKW_DrK);
612        %put &amp;amp;VKW_DrK.;
WARNING: Apparent symbolic reference VKW_DRK not resolved.
&amp;amp;VKW_DrK.
613        call symputx ('Dateiname',cats('Dr_Klein_KW_Reporting_',Jahr,'_KW',&amp;amp;VKW_DrK.));
                                                                              _
                                                                              386
                                                                              200
                                                                              76
WARNING: Apparent symbolic reference VKW_DRK not resolved.
614        call symputx('Zeitraum', cats(Jahr,'_KW',&amp;amp;VKW_DrK.));
                                                    _
                                                    386
                                                    200
                                                    76
WARNING: Apparent symbolic reference VKW_DRK not resolved.
ERROR 386-185: Expecting an arithmetic expression.

ERROR 200-322: The symbol is not recognized and will be ignored.

ERROR 76-322: Syntax error, statement will be ignored.

615        run;

NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
      610:20   611:23   
NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
      610:11   
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.KW_DRK may be incomplete.  When this step was stopped there were 0 observations and 9 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

WARNING: Apparent symbolic reference DATEINAME not resolved.
WARNING: Apparent symbolic reference ZEITRAUM not resolved.
616        %put &amp;amp;Dateiname. &amp;amp;Zeitraum.;
&amp;amp;Dateiname. &amp;amp;Zeitraum.&lt;/PRE&gt;&lt;P&gt;how can I correct this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;PY&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jun 2021 12:17:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/error-in-a-dataset-with-dates/m-p/747314#M29478</guid>
      <dc:creator>PierreYvesILY</dc:creator>
      <dc:date>2021-06-11T12:17:24Z</dc:date>
    </item>
    <item>
      <title>Re: error in a dataset with dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/error-in-a-dataset-with-dates/m-p/747316#M29479</link>
      <description>&lt;P&gt;You are expecting the &amp;amp;VKW_DrK will be available in the same DATA step that creates it.&amp;nbsp; But that's not true,&amp;nbsp; It's not available until after the RUN statement causes the DATA step to execute.&amp;nbsp; Luckily, you already have a DATA step variable you can use instead.&amp;nbsp; Change this code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call symput('VKW_DrK',VKW_DrK);
%put &amp;amp;VKW_DrK.;
call symputx ('Dateiname',cats('Dr_Klein_KW_Reporting_',Jahr,'_KW',&amp;amp;VKW_DrK.));
call symputx('Zeitraum', cats(Jahr,'_KW',&amp;amp;VKW_DrK.));
run;
%put &amp;amp;Dateiname. &amp;amp;Zeitraum.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Instead, use:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call symput('VKW_DrK',VKW_DrK);
call symputx ('Dateiname',cats('Dr_Klein_KW_Reporting_',Jahr,'_KW',VKW_DrK));
call symputx('Zeitraum', cats(Jahr,'_KW',VKW_DrK));
run;
%put &amp;amp;Dateiname. &amp;amp;Zeitraum.;
%put &amp;amp;VKW_Drk;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Jun 2021 12:28:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/error-in-a-dataset-with-dates/m-p/747316#M29479</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2021-06-11T12:28:09Z</dc:date>
    </item>
    <item>
      <title>Re: error in a dataset with dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/error-in-a-dataset-with-dates/m-p/747318#M29480</link>
      <description>&lt;P&gt;Macro variable &amp;amp;VKW_DrK cannot be used in the same DATA step as it was created in (by CALL SYMPUTX one or two lines above).&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Why do you need this to be a macro variable, anyway? A regular DATA step variable ought to work (partial code)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;VKW_DrK = compress(VKW_DrK);
call symputx ('Dateiname',cats('Dr_Klein_KW_Reporting_',Jahr,'_KW',VKW_DrK));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Jun 2021 12:30:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/error-in-a-dataset-with-dates/m-p/747318#M29480</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-06-11T12:30:21Z</dc:date>
    </item>
    <item>
      <title>Re: error in a dataset with dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/error-in-a-dataset-with-dates/m-p/747325#M29481</link>
      <description>Hallo Paige,&lt;BR /&gt;&lt;BR /&gt;I use &amp;amp;VKW_DrK. in the programm further, which is the reason why I need it.&lt;BR /&gt;Your code worked, thank you.&lt;BR /&gt;&lt;BR /&gt;Have a nice WE,&lt;BR /&gt;Regards&lt;BR /&gt;PY</description>
      <pubDate>Fri, 11 Jun 2021 12:54:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/error-in-a-dataset-with-dates/m-p/747325#M29481</guid>
      <dc:creator>PierreYvesILY</dc:creator>
      <dc:date>2021-06-11T12:54:09Z</dc:date>
    </item>
    <item>
      <title>Re: error in a dataset with dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/error-in-a-dataset-with-dates/m-p/747326#M29482</link>
      <description>Hallo,&lt;BR /&gt;&lt;BR /&gt;I use &amp;amp;VKW_DrK. in the programm further, which is the reason why I need it.&lt;BR /&gt;Your code worked, thank you.&lt;BR /&gt;&lt;BR /&gt;Have a nice WE,&lt;BR /&gt;Regards&lt;BR /&gt;PY</description>
      <pubDate>Fri, 11 Jun 2021 12:54:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/error-in-a-dataset-with-dates/m-p/747326#M29482</guid>
      <dc:creator>PierreYvesILY</dc:creator>
      <dc:date>2021-06-11T12:54:44Z</dc:date>
    </item>
    <item>
      <title>Re: error in a dataset with dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/error-in-a-dataset-with-dates/m-p/747329#M29483</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;In addition to the other comments:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Note that the %PUT statement (a macro statement, as opposed to a DATA step statement) is executed &lt;EM&gt;before&lt;/EM&gt; the DATA step is &lt;EM&gt;compiled&lt;/EM&gt;. So, even if a macro variable&amp;nbsp;&lt;FONT face="courier new,courier"&gt;VKW_DrK&lt;/FONT&gt; existed at that point of time, its value would be written to the log in the middle of the DATA step &lt;EM&gt;code&lt;/EM&gt;, but regardless of what happens during DATA step execution. In fact, it would be written to the log even if DATA step compilation failed with a syntax error that occurred before the %PUT statement. Therefore, as a rule, %PUT (and %LET) statements have their place outside of DATA steps.&lt;/LI&gt;
&lt;LI&gt;The statement&lt;BR /&gt;
&lt;PRE&gt;VKW_DrK = compress(VKW_DrK);&lt;/PRE&gt;
would make sense for a &lt;EM&gt;character&lt;/EM&gt; variable &lt;FONT face="courier new,courier"&gt;VKW_DrK&lt;/FONT&gt;, but your code suggests that this is a numeric variable. In this case the statement only produces two ugly log messages (as you see in your log, referring to line number 610) about automatic numeric-to-character conversion (in order to apply the character function COMPRESS to the initially numeric argument) and character-to-numeric conversion (in order to assign the character result from COMPRESS to the numeric variable, if possible).&lt;/LI&gt;
&lt;LI&gt;The third type conversion mentioned in the log (referring to line 611) is caused by CALL SYMPUT, applied to a numeric second argument. Using CALL SYMPUT&lt;STRONG&gt;X&lt;/STRONG&gt; instead would avoid this.&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Fri, 11 Jun 2021 13:32:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/error-in-a-dataset-with-dates/m-p/747329#M29483</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-06-11T13:32:43Z</dc:date>
    </item>
  </channel>
</rss>

