<?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 put data into different_decile_groups in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/data-into-different-groups/m-p/97038#M27397</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What Mike suggests is just the way to go if you're breaking a given data set into deciles.&amp;nbsp; But we have applications here in which you categorize one dataset based on deciles derived from another (for example size deciles from NYSE-listed companies applied to companies listed on AMEX and NASDAQ - don't ask me why):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc univariate data=nyse (keep=at) noprint;&lt;BR /&gt;&amp;nbsp; var at;&lt;BR /&gt;&amp;nbsp; output out=nyse_brkpoints&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pctlpts=0 to 100 by 10 &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pctlpre=PCTL_&amp;nbsp;&amp;nbsp; /*&amp;nbsp; vars to be named pctl_0 pctl_10 ... pctl_100 */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want (drop=pctl_:);&lt;/P&gt;&lt;P&gt;&amp;nbsp; if _n_=1 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set pctlpts;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array cats {1:10} pctl_0 -- pctl_90;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pctl_0=.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set mydata;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if not (missing(at)) then do decile=10 to 1 by -1 until (at&amp;gt;=cats{decile}); end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 17 Aug 2012 18:17:09 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2012-08-17T18:17:09Z</dc:date>
    <item>
      <title>data into different groups</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/data-into-different-groups/m-p/97036#M27395</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For each fyear I am looking to put my data into 10 different groups based on the size of AT. I would like to create a new row containing the appropriate number (between 1-10).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have heard this is achievable through commands but I cant seem to get it right. Help would be gratefully appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanking u in advance &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Aug 2012 15:19:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/data-into-different-groups/m-p/97036#M27395</guid>
      <dc:creator>redrover99</dc:creator>
      <dc:date>2012-08-17T15:19:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to put data into different_decile_groups</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/data-into-different-groups/m-p/97037#M27396</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi ... this will create a new variable (at_decile) that ranges from 0 to 9 within each year (you have a lot of missing values for AT that do not get assigned to any group ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;data have;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;infile 'z:\practice.csv' dsd firstobs=2 truncover;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;input lpermno year at;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;proc sort data=have;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;by year;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;proc rank data=have out=want groups=10;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;var at;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;ranks at_decile;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;by year;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if you use the following, you'll see 10% of the observations within each year are in each group (plus how may missing values in each year) ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;proc freq data=want;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;table year*at_decile / nocol nopercent missprint;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if you want the deciles to range from 1 to 10 you'll have to use a data step after PROC RANK to add 1 to each decile value&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Aug 2012 15:45:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/data-into-different-groups/m-p/97037#M27396</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2012-08-17T15:45:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to put data into different_decile_groups</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/data-into-different-groups/m-p/97038#M27397</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What Mike suggests is just the way to go if you're breaking a given data set into deciles.&amp;nbsp; But we have applications here in which you categorize one dataset based on deciles derived from another (for example size deciles from NYSE-listed companies applied to companies listed on AMEX and NASDAQ - don't ask me why):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc univariate data=nyse (keep=at) noprint;&lt;BR /&gt;&amp;nbsp; var at;&lt;BR /&gt;&amp;nbsp; output out=nyse_brkpoints&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pctlpts=0 to 100 by 10 &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pctlpre=PCTL_&amp;nbsp;&amp;nbsp; /*&amp;nbsp; vars to be named pctl_0 pctl_10 ... pctl_100 */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want (drop=pctl_:);&lt;/P&gt;&lt;P&gt;&amp;nbsp; if _n_=1 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set pctlpts;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array cats {1:10} pctl_0 -- pctl_90;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pctl_0=.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set mydata;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if not (missing(at)) then do decile=10 to 1 by -1 until (at&amp;gt;=cats{decile}); end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Aug 2012 18:17:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/data-into-different-groups/m-p/97038#M27397</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2012-08-17T18:17:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to put data into different_decile_groups</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/data-into-different-groups/m-p/97039#M27398</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Cool thanks guys, works hassle free!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Aug 2012 01:08:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/data-into-different-groups/m-p/97039#M27398</guid>
      <dc:creator>redrover99</dc:creator>
      <dc:date>2012-08-18T01:08:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to put data into different_decile_groups</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/data-into-different-groups/m-p/97040#M27399</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, of course :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;proc sql;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;create table wantAve as&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;select year, at_decile, mean(at) as aveAt&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;from want&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;group by year, at_decile;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;quit;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Aug 2012 01:18:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/data-into-different-groups/m-p/97040#M27399</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2012-08-18T01:18:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to put data into different_decile_groups</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/data-into-different-groups/m-p/97041#M27400</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Aug 2012 02:02:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/data-into-different-groups/m-p/97041#M27400</guid>
      <dc:creator>redrover99</dc:creator>
      <dc:date>2012-08-18T02:02:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to put data into different_decile_groups</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/data-into-different-groups/m-p/97042#M27401</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Yes, but I suspect you are trying to get year-specific deciles - at least that's what is typical here.&amp;nbsp; So if you have a DATE variable then:&lt;/P&gt;&lt;P&gt;proc univariate data=nyse noprint;&lt;BR /&gt;&amp;nbsp; var at;&lt;/P&gt;&lt;P&gt;&amp;nbsp; class date ;&amp;nbsp; format date year4.;&lt;BR /&gt;&amp;nbsp; output out=nyse_brkpoints&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pctlpts=0 to 100 by 10&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pctlpre=PCTL_&amp;nbsp;&amp;nbsp; /*&amp;nbsp; vars to be named pctl_0 pctl_10 ... pctl_100 */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;** So in the above you created one row per year.&amp;nbsp; Below put each of those rows in a row of the CATS matrix.&amp;nbsp; Assuming you have no data prior to 1980 and none after 2010, I bounded the row dimension of CATS to 1980:2010.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data want (drop=pctl_:);&lt;/P&gt;&lt;P&gt; ** First populate the CATS matrix **;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if _n_=1 then do until (end_of_pctl);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set brkpoints&amp;nbsp; end=end_of_pctl;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array pcts {1:10} pctl_0 -- pctl_90;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array cats {1980:2010,1:10}&amp;nbsp; _temporary_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; year=year(date);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do C=1 to 10; cats{year,C}=pcts{C};end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ** Now select a row in CATs to determine deciles for records in MYDATA&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set mydata;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; year=year(date);&amp;nbsp;&amp;nbsp; ** use this YEAR value to go to desired row of CATS **;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if not (missing(at)) then do decile=10 to 1 by -1 until (at&amp;gt;=cats{year,decile}); end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BTW, often you want to use last year's deciles to categorize this years' companies (numerous investment strategies do this).&amp;nbsp; If so, then change the UNTIL expression to:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; until (at&amp;gt;cats(year-1,decile))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Of course this only works if the calibration dataset has data in the year preceding the earliest year in MYDATA.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then go ahead and make means for DECILE*YEAR&amp;nbsp; or DECILE*DATE (formatted at year4.).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As to averages, &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Aug 2012 02:06:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/data-into-different-groups/m-p/97042#M27401</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2012-08-18T02:06:10Z</dc:date>
    </item>
  </channel>
</rss>

