<?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: Can Proc  Means be used in DO Loops ? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Can-Proc-Means-be-used-in-DO-Loops/m-p/74169#M21487</link>
    <description>Thanks very much.</description>
    <pubDate>Thu, 08 Apr 2010 14:46:20 GMT</pubDate>
    <dc:creator>QLi</dc:creator>
    <dc:date>2010-04-08T14:46:20Z</dc:date>
    <item>
      <title>Can Proc  Means be used in DO Loops ?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Can-Proc-Means-be-used-in-DO-Loops/m-p/74164#M21482</link>
      <description>I have a big dataset A. The main variables in Data A are fico_score, account_number, charge_off.&lt;BR /&gt;
I need to analysis these three variables. In every 5 score points range from min to max, to calculate the frequency of account_number,  total balance of charge_off and also to show the range in the output.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
The Dataset A I have like this kind:&lt;BR /&gt;
&lt;BR /&gt;
Fico_Score     Account_number     Charge_off&lt;BR /&gt;
&lt;BR /&gt;
450                  123                           2.5&lt;BR /&gt;
450                  456                            2.1&lt;BR /&gt;
451                 213                               .&lt;BR /&gt;
.....&lt;BR /&gt;
The result I expect to get likes this:&lt;BR /&gt;
Score_band     Freq_acct      Total_CO&lt;BR /&gt;
450-455            45                 21.1&lt;BR /&gt;
456- 460          23                  31.1&lt;BR /&gt;
.......&lt;BR /&gt;
&lt;BR /&gt;
I tried these codes, but it didn’t work.&lt;BR /&gt;
&lt;BR /&gt;
Data test;&lt;BR /&gt;
set a;&lt;BR /&gt;
retain Score_band  Freq_amt   Total_co;&lt;BR /&gt;
do i = 450 to 830 by 5;&lt;BR /&gt;
 proc means data = a  noprint;&lt;BR /&gt;
var account_number  charge_off;&lt;BR /&gt;
where fico_score &amp;gt;= i and Fico_score &amp;lt; i+5;&lt;BR /&gt;
output n = Freq_acct  sum = Total_Co;&lt;BR /&gt;
end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
 Could someone tell me some clues to code these?</description>
      <pubDate>Wed, 07 Apr 2010 14:28:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Can-Proc-Means-be-used-in-DO-Loops/m-p/74164#M21482</guid>
      <dc:creator>QLi</dc:creator>
      <dc:date>2010-04-07T14:28:28Z</dc:date>
    </item>
    <item>
      <title>Re: Can Proc  Means be used in DO Loops ?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Can-Proc-Means-be-used-in-DO-Loops/m-p/74165#M21483</link>
      <description>Look at the SAS macro tools.  You can do it with %DO and some of the other tools there.</description>
      <pubDate>Wed, 07 Apr 2010 15:37:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Can-Proc-Means-be-used-in-DO-Loops/m-p/74165#M21483</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2010-04-07T15:37:07Z</dc:date>
    </item>
    <item>
      <title>Re: Can Proc  Means be used in DO Loops ?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Can-Proc-Means-be-used-in-DO-Loops/m-p/74166#M21484</link>
      <description>Thanks Duke, I will try it.</description>
      <pubDate>Wed, 07 Apr 2010 15:58:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Can-Proc-Means-be-used-in-DO-Loops/m-p/74166#M21484</guid>
      <dc:creator>QLi</dc:creator>
      <dc:date>2010-04-07T15:58:15Z</dc:date>
    </item>
    <item>
      <title>Re: Can Proc  Means be used in DO Loops ?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Can-Proc-Means-be-used-in-DO-Loops/m-p/74167#M21485</link>
      <description>Assign a new variable in your dataset representing your groups, and use the BY statement with your PROC MEANS.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Wed, 07 Apr 2010 16:01:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Can-Proc-Means-be-used-in-DO-Loops/m-p/74167#M21485</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-04-07T16:01:58Z</dc:date>
    </item>
    <item>
      <title>Re: Can Proc  Means be used in DO Loops ?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Can-Proc-Means-be-used-in-DO-Loops/m-p/74168#M21486</link>
      <description>QLi,&lt;BR /&gt;
&lt;BR /&gt;
Scott's approach is much more elegant and efficient than %DO.  His approach requires roughly three passes through the data (Data step to group fico, a sort, and a means).  the %DO approach requires about 80 passes through the data (MEANS is passes the data once for each level of the index variable).</description>
      <pubDate>Wed, 07 Apr 2010 18:06:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Can-Proc-Means-be-used-in-DO-Loops/m-p/74168#M21486</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2010-04-07T18:06:15Z</dc:date>
    </item>
    <item>
      <title>Re: Can Proc  Means be used in DO Loops ?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Can-Proc-Means-be-used-in-DO-Loops/m-p/74169#M21487</link>
      <description>Thanks very much.</description>
      <pubDate>Thu, 08 Apr 2010 14:46:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Can-Proc-Means-be-used-in-DO-Loops/m-p/74169#M21487</guid>
      <dc:creator>QLi</dc:creator>
      <dc:date>2010-04-08T14:46:20Z</dc:date>
    </item>
    <item>
      <title>Re: Can Proc  Means be used in DO Loops ?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Can-Proc-Means-be-used-in-DO-Loops/m-p/74170#M21488</link>
      <description>Scott,&lt;BR /&gt;
&lt;BR /&gt;
Could you please teach me how to assign the group variable?&lt;BR /&gt;
&lt;BR /&gt;
The Fico Score value in the dataset likes this &lt;BR /&gt;
Fico Score&lt;BR /&gt;
412&lt;BR /&gt;
412&lt;BR /&gt;
413&lt;BR /&gt;
413&lt;BR /&gt;
413&lt;BR /&gt;
414&lt;BR /&gt;
414&lt;BR /&gt;
415&lt;BR /&gt;
416&lt;BR /&gt;
&lt;BR /&gt;
 &lt;BR /&gt;
  How can I assign the variable to make, every 5 point as one group?&lt;BR /&gt;
&lt;BR /&gt;
What I expect the result likes this&lt;BR /&gt;
Fico Score		                        Group&lt;BR /&gt;
412		                    1&lt;BR /&gt;
412		                    1&lt;BR /&gt;
413		                    1&lt;BR /&gt;
413		                    1&lt;BR /&gt;
413		                     1&lt;BR /&gt;
414		                      1&lt;BR /&gt;
414		                         1&lt;BR /&gt;
415		                      1&lt;BR /&gt;
416		                      1</description>
      <pubDate>Thu, 08 Apr 2010 14:58:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Can-Proc-Means-be-used-in-DO-Loops/m-p/74170#M21488</guid>
      <dc:creator>QLi</dc:creator>
      <dc:date>2010-04-08T14:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: Can Proc  Means be used in DO Loops ?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Can-Proc-Means-be-used-in-DO-Loops/m-p/74171#M21489</link>
      <description>Sort your input data, then in a DATA step, assign a new SAS variable with an incrementing value to represent each unique "group-range", and each time the current observation has exceeded your previous group-range, increment the new variable.  Finally use the new variable you created with a PROC MEANS BY group processing.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 08 Apr 2010 16:01:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Can-Proc-Means-be-used-in-DO-Loops/m-p/74171#M21489</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-04-08T16:01:27Z</dc:date>
    </item>
    <item>
      <title>Re: Can Proc  Means be used in DO Loops ?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Can-Proc-Means-be-used-in-DO-Loops/m-p/74172#M21490</link>
      <description>Thanks very much. I try it right now.</description>
      <pubDate>Thu, 08 Apr 2010 16:13:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Can-Proc-Means-be-used-in-DO-Loops/m-p/74172#M21490</guid>
      <dc:creator>QLi</dc:creator>
      <dc:date>2010-04-08T16:13:39Z</dc:date>
    </item>
    <item>
      <title>Re: Can Proc  Means be used in DO Loops ?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Can-Proc-Means-be-used-in-DO-Loops/m-p/74173#M21491</link>
      <description>According to your help,  I tried these codes and finally it out.&lt;BR /&gt;
data new (drop=i diff);&lt;BR /&gt;
set try;&lt;BR /&gt;
retain i 400;&lt;BR /&gt;
do ;&lt;BR /&gt;
    diff=fico_score - i;&lt;BR /&gt;
    if diff le 5 then band= i;&lt;BR /&gt;
     retain i;&lt;BR /&gt;
     else do ;&lt;BR /&gt;
	    if ( diff gt 5 and diff le 10) then i=i +5 ;&lt;BR /&gt;
		   else i=i+10;           &lt;BR /&gt;
             band =i;&lt;BR /&gt;
              retain i;&lt;BR /&gt;
              * retain band;&lt;BR /&gt;
           end;&lt;BR /&gt;
end;&lt;BR /&gt;
run;</description>
      <pubDate>Thu, 08 Apr 2010 20:47:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Can-Proc-Means-be-used-in-DO-Loops/m-p/74173#M21491</guid>
      <dc:creator>QLi</dc:creator>
      <dc:date>2010-04-08T20:47:26Z</dc:date>
    </item>
  </channel>
</rss>

