<?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: Entering a range into the %let statment in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Entering-a-range-into-the-let-statment/m-p/538194#M74024</link>
    <description>&lt;P&gt;I am assuming your proc summery is working, please find the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro runit;
	%let years = measles1900 measles1901 measles1902 measles1903 measles1904 measles1905 measles1906 measles1907 measles1908 measles1909;

	%let y_count=%sysfunc(countw(&amp;amp;years, ' '));

	%do i=1 %to &amp;amp;y_count.;
		%let year=%sysfunc(scan(&amp;amp;years,&amp;amp;i));
		%put &amp;amp;=year;
		
		proc summary data=&amp;amp;year;
		var countvalue;
		output out=total_&amp;amp;year sum=;
		run;
	%end;
	
%mend runit;
%runit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Please let us know if it worked for you.&lt;/P&gt;</description>
    <pubDate>Mon, 25 Feb 2019 06:16:28 GMT</pubDate>
    <dc:creator>Satish_Parida</dc:creator>
    <dc:date>2019-02-25T06:16:28Z</dc:date>
    <item>
      <title>Entering a range into the %let statment</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Entering-a-range-into-the-let-statment/m-p/536843#M73991</link>
      <description>&lt;P&gt;I would like to basically use the following code&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let year = measles1900 - measles2001;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;versus listing out each year&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let year = measles1900 measles1901 measles1902 measles1903 measles1904 measles1905 measles1906 measles1907 measles1908 measles1909 ...&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and so on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do I need to use a command along the lines of %nstr, etc., am I able to use an array somehow, or am I out of luck and need to resort to listing all 102 years?&lt;/P&gt;</description>
      <pubDate>Tue, 19 Feb 2019 18:05:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Entering-a-range-into-the-let-statment/m-p/536843#M73991</guid>
      <dc:creator>postollma</dc:creator>
      <dc:date>2019-02-19T18:05:35Z</dc:date>
    </item>
    <item>
      <title>Re: Entering a range into the %let statment</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Entering-a-range-into-the-let-statment/m-p/536844#M73992</link>
      <description>It depends entirely on how you're planning to use this macro variable later on.</description>
      <pubDate>Tue, 19 Feb 2019 18:07:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Entering-a-range-into-the-let-statment/m-p/536844#M73992</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-02-19T18:07:16Z</dc:date>
    </item>
    <item>
      <title>Re: Entering a range into the %let statment</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Entering-a-range-into-the-let-statment/m-p/536848#M73993</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;I have measles(YEAR) as different datasets.&lt;/P&gt;&lt;P&gt;After that let statement, I want to do a proc summary as follows:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=&amp;amp;year;
var countvalue;
output out=total_&amp;amp;year sum=;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;so that I can get column totals for the variable countvalue by year.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Feb 2019 18:15:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Entering-a-range-into-the-let-statment/m-p/536848#M73993</guid>
      <dc:creator>postollma</dc:creator>
      <dc:date>2019-02-19T18:15:40Z</dc:date>
    </item>
    <item>
      <title>Re: Entering a range into the %let statment</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Entering-a-range-into-the-let-statment/m-p/536849#M73994</link>
      <description>Then neither will work. Your code has to be valid SAS syntax and I don't believe either of those are valid SAS syntax. &lt;BR /&gt;&lt;BR /&gt;You need to either combine the data sets in a view ahead of time, or loop through and do it for each data set. I recommend create the view approach first.</description>
      <pubDate>Tue, 19 Feb 2019 18:21:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Entering-a-range-into-the-let-statment/m-p/536849#M73994</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-02-19T18:21:29Z</dc:date>
    </item>
    <item>
      <title>Re: Entering a range into the %let statment</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Entering-a-range-into-the-let-statment/m-p/536853#M73995</link>
      <description>&lt;P&gt;Maybe a CALL EXECUTE structure?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data range;
 do yr=1900 to 2001 by 1;
  year = put(yr,4.);
  call execute
  (
    "
    proc summary data=measles" || year || ";
    var countvalue;
    output out=total_" || year || " sum=;
    run;
    "
  );
 end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Feb 2019 18:31:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Entering-a-range-into-the-let-statment/m-p/536853#M73995</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2019-02-19T18:31:55Z</dc:date>
    </item>
    <item>
      <title>Re: Entering a range into the %let statment</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Entering-a-range-into-the-let-statment/m-p/537626#M74008</link>
      <description>&lt;P&gt;I assume that you want to&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;collect data from all the years in one dataset&lt;/LI&gt;
&lt;LI&gt;get the year as a variable&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you will have to collect all the data first.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let indata=measles1900-measles2001;

data v_measles/view=v_measles;
  set  &amp;amp;indata indsname=table;
  year=input(substr(table,length(table)-3),4.0);
run;
  &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I did the data collection as a view, as there is no reason to duplicate the actual data. You can now do your summary on the data step view:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=v_measles nway;
  var countvalue;
  class year;
  output out=total sum=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Feb 2019 10:19:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Entering-a-range-into-the-let-statment/m-p/537626#M74008</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2019-02-22T10:19:19Z</dc:date>
    </item>
    <item>
      <title>Re: Entering a range into the %let statment</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Entering-a-range-into-the-let-statment/m-p/538194#M74024</link>
      <description>&lt;P&gt;I am assuming your proc summery is working, please find the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro runit;
	%let years = measles1900 measles1901 measles1902 measles1903 measles1904 measles1905 measles1906 measles1907 measles1908 measles1909;

	%let y_count=%sysfunc(countw(&amp;amp;years, ' '));

	%do i=1 %to &amp;amp;y_count.;
		%let year=%sysfunc(scan(&amp;amp;years,&amp;amp;i));
		%put &amp;amp;=year;
		
		proc summary data=&amp;amp;year;
		var countvalue;
		output out=total_&amp;amp;year sum=;
		run;
	%end;
	
%mend runit;
%runit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Please let us know if it worked for you.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2019 06:16:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Entering-a-range-into-the-let-statment/m-p/538194#M74024</guid>
      <dc:creator>Satish_Parida</dc:creator>
      <dc:date>2019-02-25T06:16:28Z</dc:date>
    </item>
  </channel>
</rss>

