<?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: scan in a proc data in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/scan-in-a-proc-data/m-p/288836#M59589</link>
    <description>&lt;P&gt;Thank you so much for your answer and your advice. It works very well &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Alison&lt;/P&gt;</description>
    <pubDate>Tue, 02 Aug 2016 06:56:08 GMT</pubDate>
    <dc:creator>alisondu77</dc:creator>
    <dc:date>2016-08-02T06:56:08Z</dc:date>
    <item>
      <title>scan in a proc data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/scan-in-a-proc-data/m-p/288530#M59581</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;From a macro variable declared by a user (&lt;EM&gt;year&lt;/EM&gt;), i want to have the first day of all the&amp;nbsp;month of the period.&lt;/P&gt;&lt;P&gt;For example if someone put : %let year = 2014 2015; &amp;nbsp;I want to have "01jan2014", "01feb2014", "01mar2014" ... "01nov2015" "01dec2015". I want to have this date save in different macro variable (date_1, date_2, date_3 ..., date_23, date_24).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I have made a code, which works by half. I succeed in &amp;nbsp;having the "01mmm" but not the YYYY.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%global year;
%let year = 2014 2015 ;			/* the user choose the year*/

%global nb_year;
%let nb_year=%sysfunc(countw(&amp;amp;year.));
%put &amp;amp;nb_year. ; /*count the number of years*/

/* dates are saving in date_k (date_1 for "01jan2014", date_2 for '01feb2014"d ...) */
data _null_;
k=0;
ATTRIB month LENGTH=$5 ;
 do i=1 to (&amp;amp;nb_year.);
 year2 = scan(&amp;amp;year.,i,' ') ;	/*this step doesn't work*/
 	do j=1 to 12 ;				
		if j=1 then month= "01jan";
		if j=2 then month="01feb";
		if j=3 then month="01mar";
		if j=4 then month="01apr";
		if j=5 then month="01may";
		if j=6 then month="01jun";
		if j=7 then month="01jul";
		if j=8 then month="01aug";
		if j=9 then month="01sep";
		if j=10 then month="01oct";
		if j=11 then month="01nov";
		if j=12 then month="01dec" ;
		k=k+1;
		ym=(month)||(year2);
		call symput(cats('date_',k),ym);
	end;  
 end ; 
run ;
%put &amp;amp;date_20.;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So everything works except the lign where i declare "year2".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can somenone help me to solve my problem ? Sorry for my poor english ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Alison&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2016 11:26:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/scan-in-a-proc-data/m-p/288530#M59581</guid>
      <dc:creator>alisondu77</dc:creator>
      <dc:date>2016-08-01T11:26:32Z</dc:date>
    </item>
    <item>
      <title>Re: scan in a proc data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/scan-in-a-proc-data/m-p/288540#M59583</link>
      <description>&lt;P&gt;Sorry, I really don't believe macro language is the best fit for data processing. &amp;nbsp;Its a fundamental misunderstanding of what macro code is for. &amp;nbsp;Macro is a text generation tool - it does nothing on its own, it has no data structures, it does not recognise dates or do calculation. &amp;nbsp;I would do:&lt;/P&gt;
&lt;PRE&gt;%let year = 2014 2015;

data elements;
  do i=1 to countw("&amp;amp;year."," ");
    year=input(scan("&amp;amp;year.",i," "),best.);
    do j=1 to 12;
      date=mdy(j,1,year);
      output;
    end;
  end;
  format date date9.;
run;&lt;/PRE&gt;
&lt;P&gt;You will see how simple the code is, just a couple of loops - this is the power of Base SAS using proper datatypes. &amp;nbsp;You can then use this dataset anyway you like - for instance in() lists, merging and such like. &amp;nbsp;And if you really need macro variables use call symput(), however I would strongly advise against it.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2016 11:55:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/scan-in-a-proc-data/m-p/288540#M59583</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-08-01T11:55:30Z</dc:date>
    </item>
    <item>
      <title>Re: scan in a proc data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/scan-in-a-proc-data/m-p/288541#M59584</link>
      <description>&lt;P&gt;It should be:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Year2 = scan("&amp;amp;year", i);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But you'd be better off using SAS dates.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Do j=1 to 12;
Date= mdy(j, 1, year2);&lt;BR /&gt;k+1;
Call symputx('date_'||k, put(date, date9.));
End;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Aug 2016 11:59:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/scan-in-a-proc-data/m-p/288541#M59584</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-08-01T11:59:07Z</dc:date>
    </item>
    <item>
      <title>Re: scan in a proc data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/scan-in-a-proc-data/m-p/288836#M59589</link>
      <description>&lt;P&gt;Thank you so much for your answer and your advice. It works very well &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Alison&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2016 06:56:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/scan-in-a-proc-data/m-p/288836#M59589</guid>
      <dc:creator>alisondu77</dc:creator>
      <dc:date>2016-08-02T06:56:08Z</dc:date>
    </item>
    <item>
      <title>Re: scan in a proc data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/scan-in-a-proc-data/m-p/288838#M59590</link>
      <description>&lt;P&gt;Yes, thank you it works too. I didn't know that we have to put " " around the macro-variable in a scan. Thank you ! Have a nice day &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Alison&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2016 06:58:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/scan-in-a-proc-data/m-p/288838#M59590</guid>
      <dc:creator>alisondu77</dc:creator>
      <dc:date>2016-08-02T06:58:18Z</dc:date>
    </item>
  </channel>
</rss>

