<?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 Macro to create diff referral date per dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-diff-referral-date-per-dataset/m-p/648063#M194043</link>
    <description>&lt;P&gt;Hi!&amp;nbsp; I have 4 data sets, data1-date4.&amp;nbsp; I need a referral_date variable for each data set that corresponds to the dataset name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For instance, in data1 referral_date=January2020 and in data2 referral_date=February2020.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to know how to do this in a macro since creating a variable for each dataset individually takes up time and space. Thanks!&lt;/P&gt;</description>
    <pubDate>Fri, 15 May 2020 15:12:25 GMT</pubDate>
    <dc:creator>jmmedina25</dc:creator>
    <dc:date>2020-05-15T15:12:25Z</dc:date>
    <item>
      <title>Macro to create diff referral date per dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-diff-referral-date-per-dataset/m-p/648063#M194043</link>
      <description>&lt;P&gt;Hi!&amp;nbsp; I have 4 data sets, data1-date4.&amp;nbsp; I need a referral_date variable for each data set that corresponds to the dataset name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For instance, in data1 referral_date=January2020 and in data2 referral_date=February2020.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to know how to do this in a macro since creating a variable for each dataset individually takes up time and space. Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2020 15:12:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-diff-referral-date-per-dataset/m-p/648063#M194043</guid>
      <dc:creator>jmmedina25</dc:creator>
      <dc:date>2020-05-15T15:12:25Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to create diff referral date per dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-diff-referral-date-per-dataset/m-p/648065#M194045</link>
      <description>&lt;P&gt;You don't need a macro just a data step. The INDSNAME option on a Set statement indicates the current data set a current record comes from. So:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data example;
   length reference_name $ 32.;
   set sashelp.class indsname=tempname;
   reference_name = scan(tempname,2);
run;&lt;/PRE&gt;
&lt;P&gt;The reference_name variable will have the value CLASS for each record as that is the name. If you want the library as well make the reference name longer (max 41) and don't use scan.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This will work for multiple sets so if there are multiple data sets on the SET statement the value of Reference_name changes with the changing data set source.&lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2020 15:20:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-diff-referral-date-per-dataset/m-p/648065#M194045</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-05-15T15:20:53Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to create diff referral date per dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-diff-referral-date-per-dataset/m-p/648068#M194048</link>
      <description>&lt;P&gt;Since adding a variable requires a rewrite of the dataset, you won't get around the time it takes to read and write the whole dataset. Why don't you add the variable later, when processing these datasets?&lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2020 15:23:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-diff-referral-date-per-dataset/m-p/648068#M194048</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-05-15T15:23:01Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to create diff referral date per dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-diff-referral-date-per-dataset/m-p/648071#M194050</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/261072"&gt;@jmmedina25&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to know how to do this in a macro since creating a variable for each dataset individually takes up time and space. Thanks!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Assuming your dates are hardcoded so that the first date is Jan2020.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
date_start = '01Jan2020';
do i=1 to 4;
call symputx(
    catt( 'referral_date', put(i, 2. -l) ), 
    catt( put(date_start, monname12.), put(date_start, year4.) )
    );


date_start = intnx('month', date_start, 1, 'b');
end;

run;

%put referral_date1.;
%put referral_date2;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 May 2020 15:29:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-diff-referral-date-per-dataset/m-p/648071#M194050</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-05-15T15:29:08Z</dc:date>
    </item>
  </channel>
</rss>

