<?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: Macro Loop for unknown Colums Count in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-for-unknown-Colums-Count/m-p/226386#M40743</link>
    <description>&lt;P&gt;I think PowerStat same with GINI but i'm not sure. Also i don't know how can i perform the GINI function on this code .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This warning message was occured because i forgot the change name of the variable default.(WARNING: The variable default in the DROP, KEEP, or RENAME list has never been referenced.).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;But there is a problem here again i'll check again thanks everyone&lt;/P&gt;</description>
    <pubDate>Fri, 18 Sep 2015 20:13:59 GMT</pubDate>
    <dc:creator>turcay</dc:creator>
    <dc:date>2015-09-18T20:13:59Z</dc:date>
    <item>
      <title>Macro Loop for unknown Colums Count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-for-unknown-Colums-Count/m-p/225814#M40576</link>
      <description>&lt;P&gt;Hello, I need a Loop to calculate thousands PowerStat value for all "Data" columns in my code. Then i have to put all PowerStat values in new table like below. Couldyou help me , please ?&amp;nbsp;&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/153i30CB651003077A7F/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="ABS.png" title="ABS.png" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=work.default;
by descending Data;
run;
data work.cumulative;
  set work.default;
  NonDefault=1-Default;
  by data notsorted;
  if first.default then defaultRate=0;
    defaultRate+default;
if first.default then NondefaultRate=0;
    NondefaultRate+Nondefault;
run;
proc sql;
create table work.cumulative2 as 
select default,data,NonDefault,defaultRate,NondefaultRate,sum(default) as TotalDefault,sum(NonDefault) as TotalNonDefault
from work.cumulative;
quit;
data PowerStat;
set work.cumulative2 END=lastN;
ResultD=defaultRate/TotalDefault;
ResultND=NondefaultRate/TotalNonDefault;
Retain Sonuc 0 MaxSonuc 0;
Area=(ResultND+Lag(ResultND))/2*(ResultD-Lag(ResultD));
IF missing(Area)=1 then Area2=0;
Else Area2=Area;
Sonuc=Sonuc+Area2;
if Sonuc&amp;gt;maxSOnuc then maxsonuc=sonuc;
if lastN then do;
PowerStat=(MaxSonuc-0.5)*2;
ABSResult=ABS(PowerStat);
output;
keep maxsonuc powerstat absresult;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Sep 2015 14:43:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-for-unknown-Colums-Count/m-p/225814#M40576</guid>
      <dc:creator>turcay</dc:creator>
      <dc:date>2015-09-16T14:43:45Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Loop for unknown Colums Count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-for-unknown-Colums-Count/m-p/225856#M40588</link>
      <description>&lt;P&gt;I think you need to tell us something about the data you start with. Hard to tell how to get the end without a start.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Sep 2015 14:59:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-for-unknown-Colums-Count/m-p/225856#M40588</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-09-16T14:59:59Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Loop for unknown Colums Count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-for-unknown-Colums-Count/m-p/225860#M40590</link>
      <description>Assuming you want to do this over many different datasets:&lt;BR /&gt;1. Create a macro that calculates the output and appends it to a master table&lt;BR /&gt;%powerstat(datain=, var=, dataout=);&lt;BR /&gt;2. Create a dataset that is a list of all datasets that need to be processed with the variable that needs to be executed.&lt;BR /&gt;3. Use Call execute to call macro from #1</description>
      <pubDate>Wed, 16 Sep 2015 15:10:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-for-unknown-Colums-Count/m-p/225860#M40590</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-09-16T15:10:02Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Loop for unknown Colums Count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-for-unknown-Colums-Count/m-p/225869#M40593</link>
      <description>&lt;P&gt;Sorry for missing information. Here is my datalines and my code. I have thousands "Data" columns. Thanks &amp;nbsp;to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;&amp;nbsp;i can calcuate &amp;nbsp;ABSPowerStat for first Data column but i tried some macros to calculate for all "Data" columns &amp;nbsp;but i failed. I'm new on macro language. Could you help me ,please ?&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/154iB02F9510FEA6569D/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="ABS.png" title="ABS.png" /&gt;&lt;/P&gt;&lt;P&gt;Data0005 &amp;nbsp; &amp;nbsp; .......&lt;/P&gt;&lt;P&gt;Data0006 &amp;nbsp; &amp;nbsp; &amp;nbsp;.........&lt;/P&gt;&lt;P&gt;Data0007 &amp;nbsp; &amp;nbsp;...........&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;BR /&gt;data defaultCok;
	length default 8. Data 8. Data2 8. Data3 8. ;
	infile datalines missover;
	input Default Data Data2  Data3;
	datalines;
0 4.15 5.15 4.00
1 0.03 5.50 3.50
0 1.53 1.70 3.05
1 0.32 0.47 2.50
1 0.03 0.90 1.70
0 0.61 0.00 3.70
0 0.78 0.80 2.70
1 0.00 2.90 4.10
0 0.70 2.09 0.00
1 0.09 3.00 2.90
1 0.00 4.00 0.00
1 2.81 4.02 0.10
0 0.47 5.00 2.90
1 1.92 4.00 4.50
1 0.01 3.50 3.00
0 0.69 2.10 1.70
;
proc sort data=work.defaultCok;
by descending Data;
run;
data work.cumulative;
  set work.defaultCok;
  NonDefault=1-Default;
  by data notsorted;
  if first.default then defaultRate=0;
    defaultRate+default;
if first.default then NondefaultRate=0;
    NondefaultRate+Nondefault;
run;
/*proc sql;
create table yeni as
  select data,(select SUM(default) from work.default as def2 where def2.data &amp;lt;= def1.data) as defaultRate
   from work.default def1
  order by data desc;*/
proc sql;
create table work.cumulative2 as 
select default,data,NonDefault,defaultRate,NondefaultRate,sum(default) as TotalDefault,sum(NonDefault) as TotalNonDefault
from work.cumulative;
quit;
data PowerStat;
set work.cumulative2 END=lastN;
ResultD=defaultRate/TotalDefault;
ResultND=NondefaultRate/TotalNonDefault;
Retain Sonuc 0 MaxSonuc 0;
Area=(ResultND+Lag(ResultND))/2*(ResultD-Lag(ResultD));
IF missing(Area)=1 then Area2=0;
Else Area2=Area;
Sonuc=Sonuc+Area2;
if Sonuc&amp;gt;maxSOnuc then maxsonuc=sonuc;
if lastN then do;
PowerStat=(MaxSonuc-0.5)*2;
ABSResult=ABS(PowerStat);
output;
keep absresult;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Sep 2015 15:29:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-for-unknown-Colums-Count/m-p/225869#M40593</guid>
      <dc:creator>turcay</dc:creator>
      <dc:date>2015-09-16T15:29:11Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Loop for unknown Colums Count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-for-unknown-Colums-Count/m-p/225889#M40596</link>
      <description>&lt;P&gt;I'm assuming the vars to be analyzed are Data1-Datax (you had Data Data2.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With that assumption the following code will do what you need, I beieve.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data results;
  length ColumnName $32 PowerStat 8 ;
  stop;
run;
%macro iterate(dataCols=1);
%do dataCol = 1 %to &amp;amp;dataCols.;
proc sort data=work.defaultCok(rename=(data&amp;amp;DataCol.=data)) out=work.defaultCok2;
  by descending Data;
run;
data work.cumulative;
  set work.defaultCok2;
  NonDefault=1-Default;
  by data notsorted;
  if first.default then defaultRate=0;
    defaultRate+default;
if first.default then NondefaultRate=0;
    NondefaultRate+Nondefault;
run;

proc sql;
create table work.cumulative2 as 
select default,data,NonDefault,defaultRate,NondefaultRate,sum(default) as TotalDefault,sum(NonDefault) as TotalNonDefault
from work.cumulative;
quit;
data PowerStat;
set work.cumulative2 END=lastN;
ResultD=defaultRate/TotalDefault;
ResultND=NondefaultRate/TotalNonDefault;
Retain Sonuc 0 MaxSonuc 0;
Area=(ResultND+Lag(ResultND))/2*(ResultD-Lag(ResultD));
IF missing(Area)=1 then Area2=0;
Else Area2=Area;
Sonuc=Sonuc+Area2;
if Sonuc&amp;gt;maxSOnuc then maxsonuc=sonuc;
if lastN then do;
PowerStat=(MaxSonuc-0.5)*2;
ABSResult=ABS(PowerStat);
varName="data&amp;amp;datacol.";
output;
keep absresult varName;
end;
run;

data results;
  set results Powerstat(rename=(absresult=Powerstat varName=ColumnName));
run;
%end;
%mend;
%iterate(dataCols=3) * number of DataX columns ;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Sep 2015 16:52:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-for-unknown-Colums-Count/m-p/225889#M40596</guid>
      <dc:creator>ChrisWard</dc:creator>
      <dc:date>2015-09-16T16:52:36Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Loop for unknown Colums Count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-for-unknown-Colums-Count/m-p/225896#M40600</link>
      <description>&lt;P&gt;You have two issue here and to properly fix this you need to address both.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first problem is that your program does not work. &amp;nbsp;Your data step immediately after the PROC SORT is referencing FIRST.DEFAULT and does not include a BY DEFAULT statement.&lt;/P&gt;&lt;P&gt;Perhaps if you could explain what the code is trying to do it could be re-written to do it in a way that would be easier to extend to multple variables?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are a few ways that immediately come to mind to applying calculations to multiple variables.&lt;/P&gt;&lt;P&gt;1) You could create arrays of an the loop over the array. &amp;nbsp;This program does not look like it would work for that, but perhaps the code could be re-written so that it could.&lt;/P&gt;&lt;P&gt;2) You could structure the data so that you could use BY variable processing. &amp;nbsp;In this case you could convert from three columns (DATA, DATA2, DATA3) to three rows with two columns VARNAME and VALUE and then process the VALUE column as you are currently processing the DATA column, but add VARNAME as a BY group. &amp;nbsp;PROC TRANSPOSE would do that easily.&lt;/P&gt;&lt;P&gt;3) As a last resort create a macro that takes the variable name as in input parameter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To make a macro you need to decide what is that varies between diffferent calls to macro. That is what are the parameters. &amp;nbsp;I think that you want the name of the variable as the parameter. &amp;nbsp;So you would call it first with DATA then DATA2 then DATA3 etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Sep 2015 17:14:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-for-unknown-Colums-Count/m-p/225896#M40600</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-09-16T17:14:32Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Loop for unknown Colums Count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-for-unknown-Colums-Count/m-p/225939#M40611</link>
      <description>&lt;P&gt;Thank you Chris. I take the output but also it gives error like below.The other problem is, it takes so long time. Maybe i have to change the code or need to get &amp;nbsp;more efficent macro.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: Variable DATA1 not found.&lt;/P&gt;&lt;P&gt;WARNING: The data set WORK.DEFAULTCOK2 may be incomplete. When this step was stopped there were 0 observations and 0 variables.&lt;BR /&gt;WARNING: Data set WORK.DEFAULTCOK2 was not replaced because this step was stopped.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Sep 2015 20:36:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-for-unknown-Colums-Count/m-p/225939#M40611</guid>
      <dc:creator>turcay</dc:creator>
      <dc:date>2015-09-16T20:36:21Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Loop for unknown Colums Count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-for-unknown-Colums-Count/m-p/225943#M40612</link>
      <description>&lt;P&gt;Hello Tom.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;"The first problem is that your program does not work. &amp;nbsp;Your data step immediately after the PROC SORT is referencing FIRST.DEFAULT and does not include a BY DEFAULT statement." I think my porgram works and DEFAULT is my constant column and in this step&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if first.default then defaultRate=0;
    defaultRate+default;
if first.default then NondefaultRate=0;
    NondefaultRate+Nondefault;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I got column's cumulative values. Did i make mistake ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I am trying do,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;1- Take cumulative values of&amp;nbsp;"default" column&lt;/P&gt;&lt;P&gt;2-Convert "default1 column's values&lt;/P&gt;&lt;P&gt;3-Take cumulative values of "Nondefault"column&lt;/P&gt;&lt;P&gt;4- I need sum&amp;nbsp;of "default" and "Nondefault" columns&lt;/P&gt;&lt;P&gt;5-defaultCumulative/sumDefault-&amp;gt;ResultD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;NondefaulCumulative/sumNonDefault-&amp;gt;ResultND&lt;/P&gt;&lt;P&gt;6 Then i perform the PowerStat formula in the Powerstat Data step&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Sep 2015 20:58:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-for-unknown-Colums-Count/m-p/225943#M40612</guid>
      <dc:creator>turcay</dc:creator>
      <dc:date>2015-09-16T20:58:12Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Loop for unknown Colums Count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-for-unknown-Colums-Count/m-p/225951#M40617</link>
      <description>&lt;P&gt;If you want to use FIRST.DEFAULT then the variable DEFAULT needs to be in the BY statement. Otherwise you will get a warning from SAS that FIRST.DEFAULT is uniniatilzed and FIRST.DEFAULT will never be true.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So what is meaning of the variable DEFAULTRATE that you are trying to calculate? &amp;nbsp;Are just making a running count of the number of times that DEFAULT=1? &amp;nbsp;And NONDEFAULTRATE is a running count of number of times that DEFAULT=0?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If so then it would clearer and easier to skip the IF/THEN and FIRST. references and just code:&lt;/P&gt;&lt;P&gt;DEFAULTRATE + DEFAULT;&lt;/P&gt;&lt;P&gt;NONDEFAULTRATE + (NOT DEFAULT);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is the PROC SQL step doing? It looks like it is just merging on the sum(), but perhaps there is something else happening there?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is the meaning of POWERSTAT? &amp;nbsp;What does it mean in words? Is it some type of Power Statistic? If so which one? What formula are you using? &amp;nbsp;Do you have a reference? &amp;nbsp;Is it possible that it is a standard statistic that an existing SAS PROC can calculate for you? That &amp;nbsp;would be a lot easier than writing your own formula.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Sep 2015 21:47:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-for-unknown-Colums-Count/m-p/225951#M40617</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-09-16T21:47:37Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Loop for unknown Colums Count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-for-unknown-Colums-Count/m-p/225989#M40623</link>
      <description>&lt;P&gt;So here is a program that calculates your statistic. &amp;nbsp;Sorry if I messed up your carefully crafted caMeLcAse variable names. The results for these three order variables with this pattern of DEFAULT values is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data1= 0.61905&lt;/P&gt;&lt;P&gt;Data2= 0.26984&lt;BR /&gt;Data3= 0.01587&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;* Sample data with three order variables ;
data defaultCok;
	infile datalines truncover;
	input Default Data1-Data3;
	datalines;
0 4.15 5.15 4.00
1 0.03 5.50 3.50
0 1.53 1.70 3.05
1 0.32 0.47 2.50
1 0.03 0.90 1.70
0 0.61 0.00 3.70
0 0.78 0.80 2.70
1 0.00 2.90 4.10
0 0.70 2.09 0.00
1 0.09 3.00 2.90
1 0.00 4.00 0.00
1 2.81 4.02 0.10
0 0.47 5.00 2.90
1 1.92 4.00 4.50
1 0.01 3.50 3.00
0 0.69 2.10 1.70
;

* Convert to vertical to be able to process by variable ;
data vertical ;
   set defaultCok;
   array d data1-data3 ;
   length varname $32 ;
   do over d ;
     varname = vname(d);
     value = d ;
     output;
   end;
   keep default varname value ;
run;

* Order by descending value within each order variable ;
proc sort data=vertical;
  by varname descending value ;
run;

* Calculate PowerStat ;
data stats ;
  call missing(of totaldefault totalnondefault sonuc maxsonuc defaultrate nondefaultrate);
  do until (last.varname);
     set vertical ;
     by varname ;
     totaldefault = sum(totaldefault,default);
     totalnondefault = sum(totalnondefault,not default);
  end;
  do until (last.varname);
     set vertical ;
     by varname ;
     defaultRate=sum(defaultrate,default);
     nondefaultRate=sum(nondefaultrate,not default);
     ResultD=defaultRate/TotalDefault;
     ResultND=NondefaultRate/TotalNonDefault;
     if first.varname then area=0;
     else Area=(ResultND+LagResultND)/2*(ResultD-LagResultD) ;
     Sonuc=sum(Sonuc,Area);
     maxsonuc = max(maxsonuc,sonuc);
     lagResultD = ResultD ;
     lagResultND = ResultND ;
   end;
   PowerStat=(MaxSonuc-0.5)*2;
   ABSResult=ABS(PowerStat);
   keep varname absresult ;
run;
proc print; run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Sep 2015 05:42:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-for-unknown-Colums-Count/m-p/225989#M40623</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-09-17T05:42:12Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Loop for unknown Colums Count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-for-unknown-Colums-Count/m-p/226025#M40636</link>
      <description>&lt;P&gt;Thank you. It seems to be working. But i changed the column "Data" (for all of them) as "Rasyo" then i put a simple macro now&amp;nbsp;all AbsResult&amp;nbsp;is gotten&amp;nbsp;same.&amp;nbsp;I can't any warning in the log tab. Have you got any idea ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let colCnt=4596;
data vertical ;
   set defaultCok;
   array d Q0001-Q&amp;amp;colCnt.;
   length Rasyo $32 ;
   do over d ;
     Rasyo = vname(d);
     value = d ;
     output;
   end;
   keep default Rasyo value ;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG title="CanSas.PNG" alt="CanSas.PNG" src="https://communities.sas.com/t5/image/serverpage/image-id/168i9C4933BC77565E13/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Sep 2015 11:41:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-for-unknown-Colums-Count/m-p/226025#M40636</guid>
      <dc:creator>turcay</dc:creator>
      <dc:date>2015-09-17T11:41:31Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Loop for unknown Colums Count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-for-unknown-Colums-Count/m-p/226044#M40647</link>
      <description>&lt;P&gt;Hard to say since you did not post any error messages.&amp;nbsp; If you change the variable name from VARNAME to RASYO in this step make sure to change it in the later steps also.&lt;/P&gt;&lt;P&gt;Are you asking why the caclculated numbers are the same?&amp;nbsp; Do they produce the same ordering of values of DEFAULT?&amp;nbsp; From your algorithm the result is totally based on the order of 1's and 0's in the variable DEFAULT to result when they are sorted by the value of the "RASYO" variable.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Sep 2015 12:59:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-for-unknown-Colums-Count/m-p/226044#M40647</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-09-17T12:59:13Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Loop for unknown Colums Count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-for-unknown-Colums-Count/m-p/226206#M40692</link>
      <description>&lt;P&gt;I just got this warning message in the Log summary;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WARNING: The variable default in the DROP, KEEP, or RENAME list has never been referenced.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Sep 2015 08:12:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-for-unknown-Colums-Count/m-p/226206#M40692</guid>
      <dc:creator>turcay</dc:creator>
      <dc:date>2015-09-18T08:12:11Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Loop for unknown Colums Count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-for-unknown-Colums-Count/m-p/226215#M40696</link>
      <description>What formula are you using to calculate PowerStat ? Maybe IML code can make it more succinct , better and faster .</description>
      <pubDate>Fri, 18 Sep 2015 09:20:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-for-unknown-Colums-Count/m-p/226215#M40696</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-09-18T09:20:15Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Loop for unknown Colums Count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-for-unknown-Colums-Count/m-p/226386#M40743</link>
      <description>&lt;P&gt;I think PowerStat same with GINI but i'm not sure. Also i don't know how can i perform the GINI function on this code .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This warning message was occured because i forgot the change name of the variable default.(WARNING: The variable default in the DROP, KEEP, or RENAME list has never been referenced.).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;But there is a problem here again i'll check again thanks everyone&lt;/P&gt;</description>
      <pubDate>Fri, 18 Sep 2015 20:13:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-for-unknown-Colums-Count/m-p/226386#M40743</guid>
      <dc:creator>turcay</dc:creator>
      <dc:date>2015-09-18T20:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Loop for unknown Colums Count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-for-unknown-Colums-Count/m-p/226545#M40778</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Actually, I need this program to be defined as a macro.&lt;/P&gt;&lt;P&gt;I mean, we have more than&amp;nbsp;hundreds of&amp;nbsp;variables to be defined sequentially in a macro.&lt;/P&gt;&lt;P&gt;There is an example in the below which shows a basic process.&lt;/P&gt;&lt;P&gt;If I can define these process with a loop, then I will be succeed in other outputs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, how can I write this program to define each value as a macro and make it change in each step with a loop process?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Can&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG title="LOOP.jpg" alt="LOOP.jpg" src="https://communities.sas.com/t5/image/serverpage/image-id/257iF55C369A816C4CFE/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; Table1&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token function"&gt;length&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;ID&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;$&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;3&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;ID&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token keyword"&gt;datalines&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;SPAN class="token data string"&gt;Q1
Q1_
Q2
Q2_
Q3
Q3_&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;

&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; _null_&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;	&lt;SPAN class="token keyword"&gt;set&lt;/SPAN&gt; Table1&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;	call &lt;SPAN class="token function"&gt;symput&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;ID&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;put&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;ID&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;3&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;SPAN class="token procnames"&gt;Data&lt;/SPAN&gt; Table2&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;Variable&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"&amp;amp;ID"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Sep 2015 12:19:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-for-unknown-Colums-Count/m-p/226545#M40778</guid>
      <dc:creator>turcay</dc:creator>
      <dc:date>2015-09-21T12:19:40Z</dc:date>
    </item>
  </channel>
</rss>

