<?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 to process the variables in dataset using macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-process-the-variables-in-dataset-using-macro/m-p/38995#M7888</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is not "stored" in an array. Arrays in SAS are just a tool to simplify referencing variables.&lt;/P&gt;&lt;P&gt;You should use macro language constructs to build code that cannot be done with the normal language.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 29 Jul 2011 15:49:52 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2011-07-29T15:49:52Z</dc:date>
    <item>
      <title>How to process the variables in dataset using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-process-the-variables-in-dataset-using-macro/m-p/38987#M7880</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am tying to shift the data in dataset using the macro. I can process the shifting using arrays, but was wondering if this could be done using Macros.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I have - Dataset with fields - variables1 to variables12 (not stored inan&amp;nbsp; Array. Each value is in separate field) &lt;/P&gt;&lt;P&gt;What I want to do - Create a new dataset using above one and call the macro inside the data step to process the shifting&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My problem -&lt;/P&gt;&lt;P&gt;(a) I want the Macro to use the variables from SET DATASET, do the processing and store the values back. I have 140 fields in the dataset and I do not want to send those as arguments to the macro.&lt;/P&gt;&lt;P&gt;(b) If I use CALL EXECUTE with the string as argument, I am getting 'Out of Memory' error as the data is huge. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible to process the data dynamically using macros for such scenario?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%MACRO SHIFT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %LET MTHCNT = %SYSFUNC(INTCK(MONTH, Date1, Date2));&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Date1, Date2 and all other variables from Dataset1&amp;nbsp; */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %LET MTHCNT1=%EVAL(&amp;amp;MTHCNT. + 1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %IF &amp;amp;MTHCNT. &amp;lt;= 12 %THEN %DO;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %DO M=&amp;amp;MTHCNT1. %TO 12 %BY 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %LET SUB=%EVAL(&amp;amp;M - &amp;amp;MTHCNT.);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Var2_&amp;amp;M&amp;nbsp; = Var2_&amp;amp;SUB;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Var3_&amp;amp;M&amp;nbsp; = Var3_&amp;amp;SUB;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Var4_&amp;amp;M&amp;nbsp; = Var4_&amp;amp;SUB;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %END;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %DO N=1 %TO &amp;amp;MTHCNT. %BY 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Var2_&amp;amp;N&amp;nbsp; = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Var3_&amp;amp;N&amp;nbsp; = ' ';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Var4_&amp;amp;N&amp;nbsp; = ' ';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %END;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %END;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %ELSE %DO;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %DO N=1 %TO 12 %BY 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Var2_&amp;amp;N&amp;nbsp; = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Var3_&amp;amp;N&amp;nbsp; = ' ';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Var4_&amp;amp;N&amp;nbsp; = ' ';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %END;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %END;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%MEND SHIFT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dataset&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt; SET&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dataset1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; BY&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Var1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CALL EXECUTE('%SHIFT');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF LAST.Va1 THEN CALL EXECUTE('OUTPUT;');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF LAST.Var1 THEN CALL EXECUTE('RUN;');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jul 2011 02:01:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-process-the-variables-in-dataset-using-macro/m-p/38987#M7880</guid>
      <dc:creator>shweta</dc:creator>
      <dc:date>2011-07-29T02:01:58Z</dc:date>
    </item>
    <item>
      <title>How to process the variables in dataset using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-process-the-variables-in-dataset-using-macro/m-p/38988#M7881</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you provide a very brief before/after example (i.e., two data steps) showing how the data looks and how you want it to look?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jul 2011 02:43:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-process-the-variables-in-dataset-using-macro/m-p/38988#M7881</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-07-29T02:43:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to process the variables in dataset using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-process-the-variables-in-dataset-using-macro/m-p/38989#M7882</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sure art297. Please see -&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let's assume Dataset1 contains 1 record with following data -&lt;/P&gt;&lt;P&gt;Var1 = 123456&lt;/P&gt;&lt;P&gt;Date1 = 1JAN2011&amp;nbsp; &lt;/P&gt;&lt;P&gt;Date2 = 1JUN2011&lt;/P&gt;&lt;P&gt;Var1_1 = 1, Var1_2 = 2, Var1_3 = 3, Var1_4 = 4,, Var1_5 = 5, Var1_6 = 6, Var1_7 = 7, Var1_8 = 8, Var1_9 = 9, Var1_10 = 10, Var1_11 = 11, Var1_12 = 12&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now based on the difference between Date1 and Date2 in Months, I want to shift the data in the record. &lt;/P&gt;&lt;P&gt;MthCnt = Diff in months (Date2 and Date1) = 6 - 1 = 5&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Diff = 5, so calculate values 6 to 12 as -&lt;/P&gt;&lt;P&gt;(I just realized that my program should decrement the value in DO loop instead of incrementing. i.e&amp;nbsp;&amp;nbsp; %DO M=12 %TO. &amp;amp;MTHCNT1. %BY -1;)&lt;/P&gt;&lt;P&gt;Var1_12 = Var1_7&amp;nbsp;&amp;nbsp;&amp;nbsp; ( 12- diff = 7)&lt;/P&gt;&lt;P&gt;Var1_11 = Var1_6&amp;nbsp;&amp;nbsp;&amp;nbsp; ( 11- diff = 6)&lt;/P&gt;&lt;P&gt;Var1_10 = Var1_5&amp;nbsp;&amp;nbsp;&amp;nbsp; ( 10- diff = 5)&lt;/P&gt;&lt;P&gt;Var1_9&amp;nbsp;&amp;nbsp; = Var1_4&amp;nbsp;&amp;nbsp;&amp;nbsp; ( 9- diff = 4)&lt;/P&gt;&lt;P&gt;Var1_8&amp;nbsp;&amp;nbsp; = Var1_3&amp;nbsp;&amp;nbsp;&amp;nbsp; ( 8- diff =3)&lt;/P&gt;&lt;P&gt;Var1_7&amp;nbsp;&amp;nbsp; = Var1_2&amp;nbsp;&amp;nbsp;&amp;nbsp; ( 7- diff = 2)&lt;/P&gt;&lt;P&gt;Var1_6&amp;nbsp;&amp;nbsp; = Var1_1&amp;nbsp;&amp;nbsp;&amp;nbsp; ( 6- diff = 1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And initialize 1 to 5 values = 0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So my final dataste should look like -&lt;/P&gt;&lt;P&gt;Var1 = 123456&lt;/P&gt;&lt;P&gt;Date1 = 1JAN2011&amp;nbsp; &lt;/P&gt;&lt;P&gt;Date2 = 1JUN2011&lt;/P&gt;&lt;P&gt;Var1_1 = 0, Var1_2 = 0, Var1_3 = 0, Var1_4 = 0,, Var1_5 = 0, &lt;/P&gt;&lt;P&gt;Var1_6 = 1, Var1_7 = 2, Var1_8 = 3, Var1_9 = 4, Var1_10 = 5, Var1_11 = 6, Var1_12 = 7&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jul 2011 03:27:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-process-the-variables-in-dataset-using-macro/m-p/38989#M7882</guid>
      <dc:creator>shweta</dc:creator>
      <dc:date>2011-07-29T03:27:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to process the variables in dataset using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-process-the-variables-in-dataset-using-macro/m-p/38990#M7883</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;this is one way you can do it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;Var1 = 123456;&lt;/P&gt;&lt;P&gt;Date1 = '1JAN2011'd; &lt;/P&gt;&lt;P&gt;Date2 = '1JUN2011'd;&lt;/P&gt;&lt;P&gt;Var1_1 = 1;&lt;/P&gt;&lt;P&gt;Var1_2 = 2;&lt;/P&gt;&lt;P&gt;Var1_3 = 3;&lt;/P&gt;&lt;P&gt;Var1_4 = 4;&lt;/P&gt;&lt;P&gt;Var1_5 = 5; &lt;/P&gt;&lt;P&gt;Var1_6 = 6;&lt;/P&gt;&lt;P&gt;Var1_7 = 7;&lt;/P&gt;&lt;P&gt;Var1_8 = 8;&lt;/P&gt;&lt;P&gt;Var1_9 = 9;&lt;/P&gt;&lt;P&gt;Var1_10 = 10; &lt;/P&gt;&lt;P&gt;Var1_11 = 11;&lt;/P&gt;&lt;P&gt;Var1_12 = 12;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;options symbolgen mprint merror mlogic;&lt;/P&gt;&lt;P&gt;%macro shift;&lt;/P&gt;&lt;P&gt;%* Get the list of the variables to be shifted;&lt;/P&gt;&lt;P&gt;proc contents data=test out=name(keep=name where=(name not in ('Var1','Date1','Date2'))); run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%* Store each variable into a macro variable;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set name nobs=cnt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; call symput(compress('name'||put(_n_,best.)),name);&lt;/P&gt;&lt;P&gt;&amp;nbsp; if _n_ =cnt then call symputx('cnt',_n_);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%* Create a macro variable storing the date difference;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set test nobs=dt_cnt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; x=intck('month',date1,date2);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; call symput(compress('dt_dif'||put(_n_,best.)),x);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if _n_ =dt_cnt then call symputx('dt_cnt',_n_);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%* Create the new dataset with the shift;&lt;/P&gt;&lt;P&gt;data new;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set test;&lt;/P&gt;&lt;P&gt; %do j=1 %to &amp;amp;dt_cnt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %do i=1 %to &amp;amp;&amp;amp;dt_dif&amp;amp;j;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;&amp;amp;name&amp;amp;i = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %do i=&amp;amp;cnt %to %eval(&amp;amp;&amp;amp;dt_dif&amp;amp;j+1) %by -1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;&amp;amp;name&amp;amp;i = &amp;amp;&amp;amp;name&amp;amp;i - &amp;amp;&amp;amp;&amp;amp;dt_dif&amp;amp;j;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt; %end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%shift&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jul 2011 04:55:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-process-the-variables-in-dataset-using-macro/m-p/38990#M7883</guid>
      <dc:creator>vrmkool</dc:creator>
      <dc:date>2011-07-29T04:55:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to process the variables in dataset using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-process-the-variables-in-dataset-using-macro/m-p/38991#M7884</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does not look like a macro issue at all.&amp;nbsp; You are just moving data around in the same row of a dataset.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set have ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; array v var1_1 - var1_12 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; diff =&amp;nbsp; intck('month',date1,date2);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i = 12 by -1 while (i-diff &amp;gt; 0);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; v(i) = v(i-diff) ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i = 1 to diff&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; v(i) = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What is it that will vary in the macro call?&amp;nbsp; The names of the array variables?&amp;nbsp; The upper limit of 12?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jul 2011 14:06:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-process-the-variables-in-dataset-using-macro/m-p/38991#M7884</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2011-07-29T14:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to process the variables in dataset using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-process-the-variables-in-dataset-using-macro/m-p/38992#M7885</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ... I agree on the "not a macro problem" ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12px; font-family: 'courier new', courier;"&gt;data have;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12px; font-family: 'courier new', courier;"&gt;Var1 = 123456;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12px; font-family: 'courier new', courier;"&gt;Date1 = '1JAN2011'd; Date2 = '1JUN2011'd;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12px; font-family: 'courier new', courier;"&gt;Var1_1 = 1; Var1_2 = 2;&amp;nbsp;&amp;nbsp; Var1_3 = 3;&amp;nbsp;&amp;nbsp; Var1_4 = 4;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12px; font-family: 'courier new', courier;"&gt;Var1_5 = 5; Var1_6 = 6;&amp;nbsp;&amp;nbsp; Var1_7 = 7;&amp;nbsp;&amp;nbsp; Var1_8 = 8;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12px; font-family: 'courier new', courier;"&gt;Var1_9 = 9; Var1_10 = 10; Var1_11 = 11; Var1_12 = 12;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12px; font-family: 'courier new', courier;"&gt;format date: date9.;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12px; font-family: 'courier new', courier;"&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12px; font-family: 'courier new', courier;"&gt;data want;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12px; font-family: 'courier new', courier;"&gt;set have;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12px; font-family: 'courier new', courier;"&gt;array v(12) var1_: ;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12px; font-family: 'courier new', courier;"&gt;diff = intck('month',date1,date2);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12px; font-family: 'courier new', courier;"&gt;do i = 1 to 12;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12px; font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; v(i) = (i gt diff) * (v(i) - diff);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12px; font-family: 'courier new', courier;"&gt;end;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12px; font-family: 'courier new', courier;"&gt;drop i diff;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12px; font-family: 'courier new', courier;"&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jul 2011 15:28:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-process-the-variables-in-dataset-using-macro/m-p/38992#M7885</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2011-07-29T15:28:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to process the variables in dataset using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-process-the-variables-in-dataset-using-macro/m-p/38993#M7886</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;vrmkool - Thank you for your response. &lt;/P&gt;&lt;P&gt;I can not use SYMPUT because date1 and date2 data varies for each record. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jul 2011 15:44:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-process-the-variables-in-dataset-using-macro/m-p/38993#M7886</guid>
      <dc:creator>shweta</dc:creator>
      <dc:date>2011-07-29T15:44:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to process the variables in dataset using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-process-the-variables-in-dataset-using-macro/m-p/38994#M7887</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom - Thank you for your response.&lt;/P&gt;&lt;P&gt;I know this can be done storing data in an Array. I just wanted to know if this could be done without using Array. Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jul 2011 15:46:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-process-the-variables-in-dataset-using-macro/m-p/38994#M7887</guid>
      <dc:creator>shweta</dc:creator>
      <dc:date>2011-07-29T15:46:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to process the variables in dataset using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-process-the-variables-in-dataset-using-macro/m-p/38995#M7888</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is not "stored" in an array. Arrays in SAS are just a tool to simplify referencing variables.&lt;/P&gt;&lt;P&gt;You should use macro language constructs to build code that cannot be done with the normal language.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jul 2011 15:49:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-process-the-variables-in-dataset-using-macro/m-p/38995#M7888</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2011-07-29T15:49:52Z</dc:date>
    </item>
    <item>
      <title>How to process the variables in dataset using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-process-the-variables-in-dataset-using-macro/m-p/38996#M7889</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ok got it. Will give this a try. Thank you &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jul 2011 15:51:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-process-the-variables-in-dataset-using-macro/m-p/38996#M7889</guid>
      <dc:creator>shweta</dc:creator>
      <dc:date>2011-07-29T15:51:34Z</dc:date>
    </item>
  </channel>
</rss>

