<?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: macros and arrays in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/macros-and-arrays/m-p/275729#M55178</link>
    <description>&lt;P&gt;Am afraid I agree with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw﻿&lt;/a&gt;&amp;nbsp;in that I have no idea what the above is trying to achieve. &amp;nbsp;Post sample test data (in the form of a datastep) and what you want the output to look like. &amp;nbsp;There is rarely a need to "loop over variables" as you call it, you can use by groups, and specify lists of variables or use automatics:&lt;BR /&gt;proc freq...;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; var _numeric_;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;For example.&lt;/P&gt;</description>
    <pubDate>Tue, 07 Jun 2016 16:12:59 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2016-06-07T16:12:59Z</dc:date>
    <item>
      <title>macros and arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macros-and-arrays/m-p/275716#M55171</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to get a macro to loop thorugh a set of variables doing the same calculations. Here is what I have&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And I am not sure if the Getvars and the macro varslist does work neither do the loop...:((((&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

%Macro GetVars(PSI) ;
 %Local VarList ;
 /* open dataset */
 %Let FID = %SysFunc(Open(&amp;amp;PSI)) ; 
 /* If accessable, process contents of dataset */
 %If &amp;amp;FID %Then %Do ;
 %Do I=1 %To %SysFunc(ATTRN(&amp;amp;FID,NVARS)) ; 
 %Let VarList= &amp;amp;VarList %SysFunc(VarName(&amp;amp;FID,&amp;amp;I));
 %End ;
 /* close dataset when complete */
 %Let FID = %SysFunc(Close(&amp;amp;FID)) ; 
 %End ;
 &amp;amp;VarList 
%Mend ;


%DO_OVER(values=



proc freq data=PSI; table ? /out=PSI_?_all noprint nocol nocum nopercent norow;run;
proc freq data=PSI; table ?/out=PSI_?_bad noprint nocol nocum nopercent norow;where Bad_final=1;run;


proc freq data=PSI_OOT; table ? /out=PSI_OOT_? all noprint nocol nocum nopercent norow;run;
proc freq data=PSI_OOT; table ?/out=PSI_OOT_?_bad noprint nocol nocum nopercent norow;where Bad_final=1;run;

Proc sql;

Create table						PSI_? as
select								
									t1.?,
									t1.Count as Dev,
									t1.Percent as Spread_DEV,
									t2.Count as OOT,
									t2.Percent as Spread_OOT,
									t3.Count as Bad_DEV,
									t3.Percent as Spread_Bad_DEV,
									t4.Count as Bad_OOT,
									t4.Percent as Spread_Bad_OOT
									

from								PSI_?_all as t1
left join							PSI_OOT_?all as t2
on									t1.? = t2.?
left join							PSI_?_bad as t3
on									t1.? = t3.?
left join							PSI_OOT_?_bad as t4
on									t1.? =t4.?
;
QUIT;


DATA PSI_?_1;
SET PSI_?;
PSI = ABS((Spread_DEV-Spread_OOT)*log(Spread_DEV/Spread_OOT))/100;
PSI_bad = ABS((Spread_bad_DEV-Spread_bad_OOT)*log(Spread_bad_DEV/Spread_bad_OOT))/100;
PSI_bad_error = PSI*PSI_bad*1000 ;
Run;

Proc Summary data=PSI_?_1 nway missing;
	VAR PSI PSI_bad PSI_bad_error;

	OUTPUT OUT=PSI_?_2 (drop=_FREQ_ _TYPE_) Sum=;
Run;

%DO_OVER(Values=varlist, PHRASE=?);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Jun 2016 16:04:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macros-and-arrays/m-p/275716#M55171</guid>
      <dc:creator>Kiteulf</dc:creator>
      <dc:date>2016-06-07T16:04:53Z</dc:date>
    </item>
    <item>
      <title>Re: macros and arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macros-and-arrays/m-p/275719#M55173</link>
      <description>&lt;P&gt;How about providing a description of your input data, some example records in the form of a datastep so we can test code and what manipulation is needed and the desired output for the example data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you apparently as a first step only counting the occurances of each value of the variables I'm pretty sure theres a better way but I can't figure out what you are attempting to do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And does the result need to be in a dataset or is this for a report?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 15:54:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macros-and-arrays/m-p/275719#M55173</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-06-07T15:54:57Z</dc:date>
    </item>
    <item>
      <title>Re: macros and arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macros-and-arrays/m-p/275726#M55176</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Should be in a dataset as I am using the data as a benchmark&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 16:07:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macros-and-arrays/m-p/275726#M55176</guid>
      <dc:creator>Kiteulf</dc:creator>
      <dc:date>2016-06-07T16:07:24Z</dc:date>
    </item>
    <item>
      <title>Re: macros and arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macros-and-arrays/m-p/275729#M55178</link>
      <description>&lt;P&gt;Am afraid I agree with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw﻿&lt;/a&gt;&amp;nbsp;in that I have no idea what the above is trying to achieve. &amp;nbsp;Post sample test data (in the form of a datastep) and what you want the output to look like. &amp;nbsp;There is rarely a need to "loop over variables" as you call it, you can use by groups, and specify lists of variables or use automatics:&lt;BR /&gt;proc freq...;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; var _numeric_;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;For example.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 16:12:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macros-and-arrays/m-p/275729#M55178</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-06-07T16:12:59Z</dc:date>
    </item>
    <item>
      <title>Re: macros and arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macros-and-arrays/m-p/276203#M55321</link>
      <description>&lt;P&gt;Sorry guys&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I fixed it with a ods output and a proc freq.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jun 2016 09:41:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macros-and-arrays/m-p/276203#M55321</guid>
      <dc:creator>Kiteulf</dc:creator>
      <dc:date>2016-06-09T09:41:00Z</dc:date>
    </item>
  </channel>
</rss>

