<?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: How do I write a macro to...import multiple text files that have the same format? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/m-p/245723#M309262</link>
    <description>&lt;P&gt;Out of curiousity, what does your question title have to do with your question?&lt;/P&gt;</description>
    <pubDate>Sun, 24 Jan 2016 19:49:39 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2016-01-24T19:49:39Z</dc:date>
    <item>
      <title>How do I write a macro to...import multiple text files that have the same format?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/m-p/245699#M309259</link>
      <description>&lt;P&gt;Hello To whomever can help me out&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are 20 variables in my data. I will need to do the same calculation for each one of them.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So how should I write a Macro that will repeat calculation for all them variable like the following code for one variable:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data Portfolio;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;set Portfolio;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Return1 = log(lag(variable1)/variable1));&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Sun, 24 Jan 2016 15:58:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/m-p/245699#M309259</guid>
      <dc:creator>BingL</dc:creator>
      <dc:date>2016-01-24T15:58:07Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write a macro to...import multiple text files that have the same format?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/m-p/245700#M309260</link>
      <description>&lt;P&gt;Actually for what you want _based on your description_...You do not need Macro. You can do it in one data step using array&amp;nbsp;like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input b d f h j k ;
cards;
2 3 4 6 88 9
2 3 4 6 88 9
2 3 4 6 88 9
6 7 8 0 4 3
;
run;

data want ;
set have;
array Variable{6} b -- i; /* Your fist variable (b) till your last variable (i)*/
array ReturnV {6};
	do i= 1 to 6;
 		ReturnV[i]=log(lag(Variable[i]) / Variable[i]);
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Just change the size to 20.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jan 2016 01:19:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/m-p/245700#M309260</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2016-01-25T01:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write a macro to...import multiple text files that have the same format?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/m-p/245706#M309261</link>
      <description>&lt;P&gt;Hello Zaki&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the solution&lt;/P&gt;&lt;P&gt;now how should i write a macro to rename those new variables as CVS_ret, VZ_ret, PEP_ret, XOM_ret etc.?&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1577i869B33AE1763DD8D/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Untitled.png" title="Untitled.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 24 Jan 2016 16:45:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/m-p/245706#M309261</guid>
      <dc:creator>BingL</dc:creator>
      <dc:date>2016-01-24T16:45:13Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write a macro to...import multiple text files that have the same format?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/m-p/245723#M309262</link>
      <description>&lt;P&gt;Out of curiousity, what does your question title have to do with your question?&lt;/P&gt;</description>
      <pubDate>Sun, 24 Jan 2016 19:49:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/m-p/245723#M309262</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-24T19:49:39Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write a macro to...import multiple text files that have the same format?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/m-p/245726#M309263</link>
      <description>&lt;P&gt;Okay&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will post this question in a new post.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Jan 2016 19:52:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/m-p/245726#M309263</guid>
      <dc:creator>BingL</dc:creator>
      <dc:date>2016-01-24T19:52:49Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write a macro to...import multiple text files that have the same format?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/m-p/245782#M309264</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input b d f h j i ;
cards;
2 3 4 6 88 9
2 3 4 6 88 9
2 3 4 6 88 9
6 7 8 5 4 3
;
run;
proc transpose data=have(obs=0) out=temp;
 var _all_;
run;

proc sql;
select cats(_name_,'_ret=log(lag(',_name_,')/',_name_,')') into : list separated by ';'
 from temp;
quit;
data want;
 set have;
 &amp;amp;list ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Jan 2016 01:31:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/m-p/245782#M309264</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-01-25T01:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write a macro to...import multiple text files that have the same format?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/m-p/245794#M309265</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp﻿&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;&lt;P&gt;your code works as well&lt;/P&gt;&lt;P&gt;thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jan 2016 03:00:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/m-p/245794#M309265</guid>
      <dc:creator>BingL</dc:creator>
      <dc:date>2016-01-25T03:00:55Z</dc:date>
    </item>
  </channel>
</rss>

