<?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 systematically process many variables once for all?! in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792851#M254055</link>
    <description>&lt;P&gt;Adding: this is why you should state the overall goal clearly, before asking questions about the details of how you create a specific string of text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS has programmed many of the standard data manipulation operations into various different PROCs, and it is frustrating to me to see people work really really really really really really hard to do something that SAS has already programmed. So, state the overall goal clearly, before you get into the details. In many cases, the overall goal has already been programmed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next time you get lost in the details of programming, maybe the better question to ask is: what is a better way to get there.&lt;/P&gt;</description>
    <pubDate>Thu, 27 Jan 2022 13:43:49 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-01-27T13:43:49Z</dc:date>
    <item>
      <title>How to systematically process many variables once for all?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792836#M254046</link>
      <description>&lt;P&gt;I have one macro which CSUMs up one variable in one dataset. It runs fine. But the issue is the data is huge with lots of variables&lt;/P&gt;
&lt;P&gt;waiting for same CSUM process. If process one variable, it is far away from being efficient.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;How to process in a systematic way? Once for all variables? Say %let varlist=var1, var2, var3, ..., var100;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If var1/2/3/.../100, read in as 100 rows in a temp dataset, then generate the code in a systematic way. I can do that.&lt;/P&gt;
&lt;P&gt;The quest is then that how to turn the varlist into a dataset(one variable name for one row)?!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro cumsum1by(ds, var, byvar); data &amp;amp;ds.(DROP = ); /*data &amp;amp;ds.(DROP = );*/ set &amp;amp;ds.; by &amp;amp;byvar.; RETAIN &amp;amp;var._csum ; &amp;amp;var._csum=coalesce(&amp;amp;var.,0)+coalesce(&amp;amp;var._csum,0) ; IF FIRST.&amp;amp;byvar. THEN &amp;amp;var._csum = coalesce(&amp;amp;var.,0) ; RUN ;quit; %mend;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 13:11:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792836#M254046</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2022-01-27T13:11:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to systematically process many variables once for all?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792837#M254047</link>
      <description>&lt;P&gt;The quest is how to turn a string line, like below, into a dataset(one string for one row).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%let varlist=var1, var2, var3, ..., var100;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 13:13:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792837#M254047</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2022-01-27T13:13:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to systematically process many variables once for all?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792840#M254049</link>
      <description>&lt;P&gt;It seems you have a longer range goal, and you are struggling with how to get there, and you have chosen the wrong tools. Arrays would allow you to pass through the data once, instead of macros that pass through the data 100 times, and is relatively simple to program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, I don't understand this:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If var1/2/3/.../100, read in as 100 rows in a temp dataset,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Variable names in rows? SAS doesn't work that way.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;What is a CSUM? Is it cumulative sum? If so, look at PROC EXPAND.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 13:27:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792840#M254049</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-01-27T13:27:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to systematically process many variables once for all?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792844#M254052</link>
      <description>&lt;P&gt;&lt;SPAN&gt;CSUM = cumulative sum&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The goal here is to CSUM up lots of variables in one dataset with by variables.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 13:28:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792844#M254052</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2022-01-27T13:28:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to systematically process many variables once for all?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792846#M254053</link>
      <description>&lt;P&gt;Trying below. The wanted outcome is(one var in a row/dataset):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;var1&lt;/P&gt;
&lt;P&gt;var2&lt;/P&gt;
&lt;P&gt;var3&lt;/P&gt;
&lt;P&gt;var4&amp;nbsp;&lt;/P&gt;
&lt;P&gt;var5&lt;/P&gt;
&lt;P&gt;varx&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let varlist=var1 var2 var3 var4 var5 var6 ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _temp; &lt;BR /&gt;input varname;&lt;BR /&gt;datalines;&lt;BR /&gt;&amp;amp;varlist.&lt;BR /&gt;;&lt;BR /&gt;run;quit;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 13:31:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792846#M254053</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2022-01-27T13:31:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to systematically process many variables once for all?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792847#M254054</link>
      <description>&lt;P&gt;PROC EXPAND is the answer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc expand data=have out=want;
    by byvariable;
    convert var1-var100 / transformout = cusum;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Jan 2022 13:32:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792847#M254054</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-01-27T13:32:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to systematically process many variables once for all?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792851#M254055</link>
      <description>&lt;P&gt;Adding: this is why you should state the overall goal clearly, before asking questions about the details of how you create a specific string of text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS has programmed many of the standard data manipulation operations into various different PROCs, and it is frustrating to me to see people work really really really really really really hard to do something that SAS has already programmed. So, state the overall goal clearly, before you get into the details. In many cases, the overall goal has already been programmed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next time you get lost in the details of programming, maybe the better question to ask is: what is a better way to get there.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 13:43:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792851#M254055</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-01-27T13:43:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to systematically process many variables once for all?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792854#M254058</link>
      <description>&lt;P&gt;Thanks. But the code is not runable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I want is that turn the string line into a dataset, which has one string in one row.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let varlist=var1 var2 var3 var4 var5 var6 ;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 13:43:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792854#M254058</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2022-01-27T13:43:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to systematically process many variables once for all?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792855#M254059</link>
      <description>&lt;P&gt;What is the reason it is not runable?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I still don't think your approach of manipulating strings is the answer. ARRAYs can also do the job, no creation of text strings needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 13:45:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792855#M254059</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-01-27T13:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to systematically process many variables once for all?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792859#M254062</link>
      <description>&lt;P&gt;Do you have SAS/IML. It is very easy for IML.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

proc iml;
use sashelp.class;
read all var _num_ into x[c=vname];
print x[c=vname l=''];

do i=1 to ncol(x);
y=y||cusum(x[,i]);
end;

print y[c=('cum_'+vname) l=''];
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1643291580974.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67925i7A4E06831D44418C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1643291580974.png" alt="Ksharp_0-1643291580974.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 13:53:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792859#M254062</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-01-27T13:53:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to systematically process many variables once for all?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792860#M254063</link>
      <description>&lt;P&gt;Thanks a huge. Sorry I never touch IML before.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 13:56:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792860#M254063</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2022-01-27T13:56:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to systematically process many variables once for all?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792861#M254064</link>
      <description>&lt;P&gt;The outcome I want is the top half. The issue is the bottom half is not working.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _temp; input varname $ @@; datalines; var1 var2 var3 var4 var5 var6 ; run;quit;&lt;/P&gt;
&lt;P&gt;_______________________________________________&lt;/P&gt;
&lt;P&gt;%let varlist=var1 var2 var3 var4 var5 var6 ;&lt;/P&gt;
&lt;P&gt;data _temp2; input varname $ @@; datalines; &amp;amp;varlist. ; run;quit;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 14:00:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792861#M254064</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2022-01-27T14:00:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to systematically process many variables once for all?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792870#M254066</link>
      <description>&lt;P&gt;Honestly, I'll pass on this string handling issue. I think it is unnecessary, and complicated, but I'm still not 100% sure I understand what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want cumulative sums, you can do that without going through all of this string handling. Do you want to see that, or not? And why doesn't PROC EXPAND work?&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 14:48:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792870#M254066</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-01-27T14:48:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to systematically process many variables once for all?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792874#M254068</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/409584"&gt;@hellohere&lt;/a&gt;,&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/409584"&gt;@hellohere&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The issue is the bottom half is not working.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(...)&lt;/P&gt;
&lt;P&gt;%let varlist=var1 var2 var3 var4 var5 var6 ;&lt;/P&gt;
&lt;P&gt;data _temp2; input varname $ @@; datalines; &amp;amp;varlist. ; run;quit;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That's because macro variable references are not resolved in data lines. But you can create and submit ("include") the DATA step code you envisioned:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename vlist temp;

data _null_;
file vlist;
put 'data _temp; input varname :$32. @@; datalines;' / "&amp;amp;varlist" / ';';
run;

%inc vlist;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Jan 2022 14:37:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792874#M254068</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-01-27T14:37:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to systematically process many variables once for all?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792885#M254072</link>
      <description>&lt;P&gt;To convert a list in macro variable into a series of observations just use a DO loop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let list=a b c d;
data list;
  length index 8 name $32 ;
  do index=1 to countw("&amp;amp;list");
    name=scan("&amp;amp;list",index);
    output;
  end;
run;  &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But why?&lt;/P&gt;
&lt;P&gt;To generate a sum many variables just use arrays.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let source=height weight age;
%let target=c_height c_weight c_age;
proc sort data=sashelp.class out=have;
  by sex;
run;

data want;
  do until(last.sex);
    set have ;
    by sex;
    array in &amp;amp;source;
    array out &amp;amp;target;
    do index=1 to dim(in);
       out[index]=sum(out[index],in[index]);
    end;
    output;
  end;
  drop index;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to generate the target names from the source names you could use something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let target=c_%sysfunc(tranwrd(&amp;amp;source,%str( ),%str( c_)));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 15:31:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792885#M254072</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-01-27T15:31:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to systematically process many variables once for all?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792896#M254075</link>
      <description>&lt;P&gt;As I read you initial macro, it does this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro cumsum1by(ds, var, byvar); 
  data &amp;amp;ds.(DROP = );
  set &amp;amp;ds.; 
  by &amp;amp;byvar.; 
  RETAIN &amp;amp;var._csum ; 
  &amp;amp;var._csum=coalesce(&amp;amp;var.,0)+coalesce(&amp;amp;var._csum,0) ; 
  IF FIRST.&amp;amp;byvar. THEN &amp;amp;var._csum = coalesce(&amp;amp;var.,0) ;
RUN ;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And you want to do that with a variable list instead of a single variable. Something like this may work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro cumsum1by(ds, vars, byvar,drop=,out=&amp;amp;ds); 
  %local i var lastby n_vars;
  %let lastby=%scan(&amp;amp;byvar,%sysfunc(countw(&amp;amp;byvar)));
  %let n_vars=%sysfunc(countw(&amp;amp;vars));
  data &amp;amp;out(DROP=&amp;amp;drop );
    set &amp;amp;ds.; 
    by &amp;amp;byvar.; 
    if first.&amp;amp;lastby then do;
      %do i=1 %to &amp;amp;n_vars;
         %let var=%scan(&amp;amp;vars,&amp;amp;i);
         &amp;amp;var._csum=0;
         %end;
      end;
     %do i=1 %to &amp;amp;n_vars;
         %let var=%scan(&amp;amp;vars,&amp;amp;i);
         &amp;amp;var._csum+&amp;amp;var;
         %end;
 RUN ;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I put in the DROP= parameter because it looked like you had thought about creating one. And I put in an OUT= parameter; although your initial macro overwrites the original dataset (which is also the default in the new version), you may want to do something else.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And then I changed the use of RETAIN and COALESCE to a SUM statement (&lt;CODE class=" language-sas"&gt;&amp;amp;var._csum+&amp;amp;var;)&lt;/CODE&gt;, which is very nifty for stuff like this: the variable added gets automatically coalesced with zero, and the receiving variable gets automatically retained.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also put in a calculation of the last of a BY variable list (&amp;amp;LAST_BY), in case you want to use more than one BY variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So an example of a call could be this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;cumsum1by(work.have,cash owed left,client_id month,drop=a c,out=test);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which will summarize the variables CASH, OWED and LEFT from WORK.HAVE by CLIENT_ID and MONTH, and output it to TEST, dropping variables A and C.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 15:44:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792896#M254075</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2022-01-27T15:44:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to systematically process many variables once for all?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792941#M254086</link>
      <description>Thanks a huge</description>
      <pubDate>Thu, 27 Jan 2022 17:50:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792941#M254086</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2022-01-27T17:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to systematically process many variables once for all?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792947#M254088</link>
      <description>&lt;P&gt;Thanks a lot still.&amp;nbsp; To CSum by var in a dataset, here are many ways to do so. The easiest one is the one with IML, which&lt;/P&gt;
&lt;P&gt;I do not use. I bet your way surely works also.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am sticky with converting string-token line&amp;nbsp; into rows in a dataset, because that is a way I know how to systematically generate&lt;/P&gt;
&lt;P&gt;code line for variables. The variable names are fluid, not just var1/var2/var3/... and not just CSum&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 18:07:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-systematically-process-many-variables-once-for-all/m-p/792947#M254088</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2022-01-27T18:07:51Z</dc:date>
    </item>
  </channel>
</rss>

