<?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: automating date variables in entire program in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/automating-date-variables-in-entire-program/m-p/536527#M6630</link>
    <description>&lt;P&gt;To accomplish that, replace all the FORMAT statements in the DATA step.&amp;nbsp; Instead of adding a format, transfer the value to a macro variable.&amp;nbsp; For example, you have:&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;
 &lt;SPAN class="token procnames"&gt;format&lt;/SPAN&gt; ThisDate DDMMYY&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
 &lt;SPAN class="token procnames"&gt;format&lt;/SPAN&gt; FirstDayOfMonth YYMMDDN6&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
 &lt;SPAN class="token procnames"&gt;format&lt;/SPAN&gt; FirstDayOfLastMonth YYMMDDN6&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/LI-CODE&gt;
&lt;P&gt;Replace that with:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call symputx('ThisDate', put(ThisDate,DDMMYY.));
call symputx('FirstDayOfMonth', put(FirstDayOfMonth, YYMMDDN6.));
call symputx('FirstDayOfLastMonth', put(FirstDayOfLastMonth, YYMMDDN6.));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;There's an assumption here that the formatted values will make sense when substituted into your program later.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 18 Feb 2019 16:44:35 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2019-02-18T16:44:35Z</dc:date>
    <item>
      <title>automating date variables in entire program</title>
      <link>https://communities.sas.com/t5/New-SAS-User/automating-date-variables-in-entire-program/m-p/535922#M6554</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to update this program I use, by automating the variables referring to dates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have managed to get all the dates in the format I want but now I would like to be able to call them during the program.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ThisDate= Date();  

   FirstDayOfMonth = IntNX("Month", ThisDate, 0);       
   FirstDayOfLastMonth = IntNX("Month", ThisDate, -1);  
   StudyStart = IntNX("Month", ThisDate, -12);            
   StudyEnd = IntNX("Month", ThisDate, 0)-1;
   OneYearAgo = IntNX("Month", ThisDate, -12); 
   date_strt = IntNX("Month", ThisDate, -15);
   date_end = IntNX("Month", ThisDate, -3)-1;
   currentyear = YEAR(FirstDayOfLastMonth);
   curntyear = YEAR(FirstDayOfLastMonth)-2000;
   monthclsng = (MONTH(FirstDayOfLastMonth));
   FirstDayOfYear = IntNX("Year", ThisDate, 0);




 format ThisDate DDMMYY.;
 format FirstDayOfMonth YYMMDDN6.;
 format FirstDayOfLastMonth YYMMDDN6.;
 format OneYearAgo YYMMDDN6.;
 format StudyStart YYMMDDN8.;
 format StudyEnd YYMMDDN8.;
 format date_strt YYMMDDN8.;
 format date_end YYMMDDN8.;
 format monthclsng Z2.;
 format FirstDayOfYear YYMMDDN6.;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I am using SAS 9.3.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 17:31:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/automating-date-variables-in-entire-program/m-p/535922#M6554</guid>
      <dc:creator>AdiBoo</dc:creator>
      <dc:date>2019-02-15T17:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: automating date variables in entire program</title>
      <link>https://communities.sas.com/t5/New-SAS-User/automating-date-variables-in-entire-program/m-p/535926#M6555</link>
      <description>&lt;P&gt;At least give us clue how/ where you want to use these values.&lt;/P&gt;
&lt;P&gt;In a single data set then use the data step code you show. Elsewhere we really need to know how you want to use them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 17:42:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/automating-date-variables-in-entire-program/m-p/535926#M6555</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-02-15T17:42:21Z</dc:date>
    </item>
    <item>
      <title>Re: automating date variables in entire program</title>
      <link>https://communities.sas.com/t5/New-SAS-User/automating-date-variables-in-entire-program/m-p/535933#M6557</link>
      <description>&lt;P&gt;Other possibly important questions:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What's the name of the data set holding these variables?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does it contain just one observation, or more than one?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 17:48:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/automating-date-variables-in-entire-program/m-p/535933#M6557</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-02-15T17:48:46Z</dc:date>
    </item>
    <item>
      <title>Re: automating date variables in entire program</title>
      <link>https://communities.sas.com/t5/New-SAS-User/automating-date-variables-in-entire-program/m-p/536426#M6623</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks for those answers, I indeed could have been a bit more specific.&lt;BR /&gt;&lt;BR /&gt;The finality was to feed the values in that particular format into the following parameters that are use throughout the program.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've inserted more code below, adding on what I previously sent.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   

data datez ;


   ThisDate= Date();  

   FirstDayOfMonth = IntNX("Month", ThisDate, 0);       
   FirstDayOfLastMonth = IntNX("Month", ThisDate, -1);  
   StudyStart = IntNX("Month", ThisDate, -12);            
   StudyEnd = IntNX("Month", ThisDate, 0)-1;
   OneYearAgo = IntNX("Month", ThisDate, -12); 
   date_strt = IntNX("Month", ThisDate, -15);
   date_end = IntNX("Month", ThisDate, -3)-1;
   currentyear = YEAR(FirstDayOfLastMonth);
   curntyear = YEAR(FirstDayOfLastMonth)-2000;
   monthclsng = (MONTH(FirstDayOfLastMonth));
   FirstDayOfYear = IntNX("Year", ThisDate, 0);




 format ThisDate DDMMYY.;
 format FirstDayOfMonth YYMMDDN6.;
 format FirstDayOfLastMonth YYMMDDN6.;
 format OneYearAgo YYMMDDN6.;
 format StudyStart YYMMDDN8.;
 format StudyEnd YYMMDDN8.;
 format date_strt YYMMDDN8.;
 format date_end YYMMDDN8.;
 format monthclsng Z2.;
 format FirstDayOfYear YYMMDDN6.;

run ;


/* parameters*/

%let base_polvig  = &amp;amp;FirstDayOfMonth    ;      
%let base_polvig_old  = &amp;amp;FirstDayOfLastMonth   ;     
%let base_polvig_old1  = &amp;amp;FirstDayOfYear   ;  
%let base_polvig_old_old  = &amp;amp;OneYearAgo    ; 		
%let annee = &amp;amp;currentyear ; 
%let an   = &amp;amp;curntyear ;
%let mois = &amp;amp;monthclsng ; 
%let deb_etude = &amp;amp;StudyStart ;   
%let fin_etude = &amp;amp;StudyEnd ;  
%let date_deb1 = &amp;amp;date_strt ;   
%let date_fin1 = &amp;amp;date_end;    


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Feb 2019 10:07:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/automating-date-variables-in-entire-program/m-p/536426#M6623</guid>
      <dc:creator>AdiBoo</dc:creator>
      <dc:date>2019-02-18T10:07:40Z</dc:date>
    </item>
    <item>
      <title>Re: automating date variables in entire program</title>
      <link>https://communities.sas.com/t5/New-SAS-User/automating-date-variables-in-entire-program/m-p/536527#M6630</link>
      <description>&lt;P&gt;To accomplish that, replace all the FORMAT statements in the DATA step.&amp;nbsp; Instead of adding a format, transfer the value to a macro variable.&amp;nbsp; For example, you have:&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;
 &lt;SPAN class="token procnames"&gt;format&lt;/SPAN&gt; ThisDate DDMMYY&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
 &lt;SPAN class="token procnames"&gt;format&lt;/SPAN&gt; FirstDayOfMonth YYMMDDN6&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
 &lt;SPAN class="token procnames"&gt;format&lt;/SPAN&gt; FirstDayOfLastMonth YYMMDDN6&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/LI-CODE&gt;
&lt;P&gt;Replace that with:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call symputx('ThisDate', put(ThisDate,DDMMYY.));
call symputx('FirstDayOfMonth', put(FirstDayOfMonth, YYMMDDN6.));
call symputx('FirstDayOfLastMonth', put(FirstDayOfLastMonth, YYMMDDN6.));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;There's an assumption here that the formatted values will make sense when substituted into your program later.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Feb 2019 16:44:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/automating-date-variables-in-entire-program/m-p/536527#M6630</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-02-18T16:44:35Z</dc:date>
    </item>
    <item>
      <title>Re: automating date variables in entire program</title>
      <link>https://communities.sas.com/t5/New-SAS-User/automating-date-variables-in-entire-program/m-p/550982#M8885</link>
      <description>&lt;P&gt;Thanks a lot &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;!&lt;BR /&gt;&lt;BR /&gt;I've had time to finish up and the call symputx function works ! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2019 09:56:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/automating-date-variables-in-entire-program/m-p/550982#M8885</guid>
      <dc:creator>AdiBoo</dc:creator>
      <dc:date>2019-04-15T09:56:33Z</dc:date>
    </item>
  </channel>
</rss>

