<?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: Predicted value and residual value for each SIC-Year in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Predicted-value-and-residual-value-for-each-SIC-Year/m-p/34900#M1455</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1)for &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; beginning at&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; the 2-digit SIC level .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;proc reg noprint data=&amp;amp;in_ds outest=oreg_ds1 edf;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; model IV=DVs;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; by fyear &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;SIC&lt;/SPAN&gt; ;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;STRONG&gt; format &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;SIC $2,&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2)for &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; beginning at&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; the 1-digit SIC level .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;proc reg noprint data=&amp;amp;in_ds outest=oreg_ds1 edf;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; model IV=DVs;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; by fyear &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;SIC&lt;/SPAN&gt; ;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; &lt;STRONG&gt;format &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;SIC $1,&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;run;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;"&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; For 2-digit industry groups with less than 20 observations, I need to form industry groups at the 1-digit SIC level."&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;I don't think it is easy to done . you need another data step to get it . E.X.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt; do i=1 to 9;&lt;/P&gt;&lt;P&gt;&amp;nbsp; sic='abcdse';output;&lt;/P&gt;&lt;P&gt; end;&lt;/P&gt;&lt;P&gt; do i=1 to 8;&lt;/P&gt;&lt;P&gt;&amp;nbsp; sic='axabd';output;&lt;/P&gt;&lt;P&gt; end;&lt;/P&gt;&lt;P&gt; do i=1 to 24;&lt;/P&gt;&lt;P&gt;&amp;nbsp; sic='oifdfe';output;&lt;/P&gt;&lt;P&gt; end;&lt;/P&gt;&lt;P&gt; do i=1 to 32;&lt;/P&gt;&lt;P&gt;&amp;nbsp; sic='ogier';output;&lt;/P&gt;&lt;P&gt; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt; create table want(drop=n _sic) as&lt;/P&gt;&lt;P&gt; select *,case when n lt 20 then substr(sic,1,1) else _sic end as flag length=2&lt;/P&gt;&lt;P&gt;&amp;nbsp; from (&lt;/P&gt;&lt;P&gt;&amp;nbsp; select *,substr(sic,1,2) as _sic length=2,count(*) as n&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; from have&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; group by calculated _sic);&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 20 Jan 2015 08:26:26 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2015-01-20T08:26:26Z</dc:date>
    <item>
      <title>Predicted value and residual value for each SIC-Year</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Predicted-value-and-residual-value-for-each-SIC-Year/m-p/34896#M1451</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good days to all;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wish to generate the predicted values and residual values by running an Ordinary Least Square (OLS). I used the following program: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc reg data=GEOG.USA;&lt;/P&gt;&lt;P&gt;Model TA=_ASSET CHANGE_SALES PPE_AT/p r;&lt;/P&gt;&lt;P&gt;Id FNA AEM;&lt;/P&gt;&lt;P&gt;output out=PRED_USA p = predicted_y r=residual_x;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;P&gt;Quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I would like to provide an additonal rules on the above regressions:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the other variables such as SIC (Industry Classification Code) and fyear (financial year). I wish to estimate the above predicted values and residual values based on the above cross-sectional model for each SIC code for each year (ie. SIC-fyear). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How should I modify the above program to incorporate the additonal criteria?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for any helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;mspak&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 17 Mar 2012 14:49:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Predicted-value-and-residual-value-for-each-SIC-Year/m-p/34896#M1451</guid>
      <dc:creator>mspak</dc:creator>
      <dc:date>2012-03-17T14:49:06Z</dc:date>
    </item>
    <item>
      <title>Predicted value and residual value for each SIC-Year</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Predicted-value-and-residual-value-for-each-SIC-Year/m-p/34897#M1452</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It looks like you need a BY statement in proc reg.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;by SIC&amp;nbsp;&amp;nbsp; fyear ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Mar 2012 07:37:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Predicted-value-and-residual-value-for-each-SIC-Year/m-p/34897#M1452</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-03-19T07:37:20Z</dc:date>
    </item>
    <item>
      <title>Predicted value and residual value for each SIC-Year</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Predicted-value-and-residual-value-for-each-SIC-Year/m-p/34898#M1453</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Ksharp,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It took a longer time to process the the program than the previous one &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;mspak&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Mar 2012 10:41:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Predicted-value-and-residual-value-for-each-SIC-Year/m-p/34898#M1453</guid>
      <dc:creator>mspak</dc:creator>
      <dc:date>2012-03-20T10:41:32Z</dc:date>
    </item>
    <item>
      <title>Re: Predicted value and residual value for each SIC-Year</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Predicted-value-and-residual-value-for-each-SIC-Year/m-p/34899#M1454</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Xia Keshan, (Or anyone else reading this!)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a very similar question with one caveat -- each cross-sectional regression needs a minimum of 20 observations beginning at the 2-digit SIC level. For 2-digit industry groups with less than 20 observations, I need to form industry groups at the 1-digit SIC level.&amp;nbsp; Can this be accomplished directly in the proc reg statement or does it need to be separately identified?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My thoughts are to create a table as such:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table mywork.comp_yi2 as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; select &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fyear,&lt;/P&gt;&lt;P&gt;&amp;nbsp; sich&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; substrn(sich,1,2) as sich_two,&lt;/P&gt;&lt;P&gt;&amp;nbsp; (count(*) GE 20) as has_twenty&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; from mywork.compf&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; group by fyear, substrn(SIC,1,2)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; having (has_twenty=1);&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And then running a pair of proc reg statements e.g.&lt;/P&gt;&lt;P&gt;For 2-digit groups having 20 observations:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc reg noprint data=&amp;amp;in_ds outest=oreg_ds1 edf;&lt;/P&gt;&lt;P&gt;&amp;nbsp; where&amp;nbsp; substrn(SIC,1,2) in mywork.comp_yi2&lt;/P&gt;&lt;P&gt;&amp;nbsp; model IV=DVs;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by fyear; substrn(SIC,1,2)&lt;/P&gt;&lt;P&gt;run; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For The 1 digit SIC level:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc reg noprint data=&amp;amp;in_ds outest=oreg_ds2 edf;&lt;/P&gt;&lt;P&gt;&amp;nbsp; where&amp;nbsp; not substrn(SIC,1,2) in mywork.comp_yi2&lt;/P&gt;&lt;P&gt;&amp;nbsp; model IV=DVs;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by fyear; substrn(SIC,1,1)&lt;/P&gt;&lt;P&gt;run; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And then mashing the two together:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc datasets lib=work;&lt;/P&gt;&lt;P&gt;&amp;nbsp; append base=oreg_ds1 data=oreg_ds2;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also -- will having the by clause mean the outtest data sets will aggregate all the cross sectional regressions, or do I need to write an iterative macro to accomplish this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Prometheus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Jan 2015 22:02:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Predicted-value-and-residual-value-for-each-SIC-Year/m-p/34899#M1454</guid>
      <dc:creator>Prometheus</dc:creator>
      <dc:date>2015-01-19T22:02:48Z</dc:date>
    </item>
    <item>
      <title>Re: Predicted value and residual value for each SIC-Year</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Predicted-value-and-residual-value-for-each-SIC-Year/m-p/34900#M1455</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1)for &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; beginning at&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; the 2-digit SIC level .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;proc reg noprint data=&amp;amp;in_ds outest=oreg_ds1 edf;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; model IV=DVs;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; by fyear &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;SIC&lt;/SPAN&gt; ;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;STRONG&gt; format &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;SIC $2,&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2)for &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; beginning at&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; the 1-digit SIC level .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;proc reg noprint data=&amp;amp;in_ds outest=oreg_ds1 edf;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; model IV=DVs;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; by fyear &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;SIC&lt;/SPAN&gt; ;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; &lt;STRONG&gt;format &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;SIC $1,&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;run;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;"&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; For 2-digit industry groups with less than 20 observations, I need to form industry groups at the 1-digit SIC level."&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;I don't think it is easy to done . you need another data step to get it . E.X.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt; do i=1 to 9;&lt;/P&gt;&lt;P&gt;&amp;nbsp; sic='abcdse';output;&lt;/P&gt;&lt;P&gt; end;&lt;/P&gt;&lt;P&gt; do i=1 to 8;&lt;/P&gt;&lt;P&gt;&amp;nbsp; sic='axabd';output;&lt;/P&gt;&lt;P&gt; end;&lt;/P&gt;&lt;P&gt; do i=1 to 24;&lt;/P&gt;&lt;P&gt;&amp;nbsp; sic='oifdfe';output;&lt;/P&gt;&lt;P&gt; end;&lt;/P&gt;&lt;P&gt; do i=1 to 32;&lt;/P&gt;&lt;P&gt;&amp;nbsp; sic='ogier';output;&lt;/P&gt;&lt;P&gt; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt; create table want(drop=n _sic) as&lt;/P&gt;&lt;P&gt; select *,case when n lt 20 then substr(sic,1,1) else _sic end as flag length=2&lt;/P&gt;&lt;P&gt;&amp;nbsp; from (&lt;/P&gt;&lt;P&gt;&amp;nbsp; select *,substr(sic,1,2) as _sic length=2,count(*) as n&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; from have&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; group by calculated _sic);&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jan 2015 08:26:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Predicted-value-and-residual-value-for-each-SIC-Year/m-p/34900#M1455</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-01-20T08:26:26Z</dc:date>
    </item>
    <item>
      <title>Re: Predicted value and residual value for each SIC-Year</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Predicted-value-and-residual-value-for-each-SIC-Year/m-p/386837#M20144</link>
      <description>&lt;P&gt;Hey! &amp;nbsp;I had the same task as mspak. &amp;nbsp;When I used the solution in the post, I was expecting to get an output that would just show residuals for each year within each industry. &amp;nbsp;Instead, SAS calculated a residual for each observation. &amp;nbsp;Is this correct? &amp;nbsp;&lt;/P&gt;&lt;P&gt;For the ultimate variable I need to calculate, I need to calculate the standard deviation of my sample firms' residual compared to the corresponding industry residual by year based on all the firms in Compustat. &amp;nbsp;Thus, I need an output from my Compustat data that a residual per each year per each industry. &amp;nbsp;Based on the SAS output this post's solution returned, I have averaged the residuals per industry per year and will use this mean residual to calculate the standard deviation I need. &amp;nbsp;Is this correct, or does anyone have a better solution? &amp;nbsp; Thanks in advance!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN&gt;&lt;STRONG&gt;reg&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN&gt;data&lt;/SPAN&gt; = Reg_Variables&amp;nbsp;&lt;/P&gt;&lt;P&gt;noprint&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;by&lt;/SPAN&gt; industry fyear;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;model&lt;/SPAN&gt; chWC_TA=lagCFO_TA CFO_TA leadCFO_TA chREV_TA chPPE_TA/&lt;SPAN&gt;r&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;output&lt;/SPAN&gt; &lt;SPAN&gt;out&lt;/SPAN&gt;=Residuals &lt;SPAN&gt;r&lt;/SPAN&gt;=residual_x;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Run&lt;/STRONG&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;SPAN&gt;;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN&gt;&lt;STRONG&gt;sql&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;; &lt;/SPAN&gt;create table&lt;SPAN&gt; Mean&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN&gt;as&lt;/SPAN&gt; &lt;SPAN&gt;select&lt;/SPAN&gt; Industry, fyear, mean(residual_x) &lt;SPAN&gt;as&lt;/SPAN&gt; ind_residual&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN&gt;from&lt;/SPAN&gt; Residuals&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN&gt;group&lt;/SPAN&gt; &lt;SPAN&gt;by&lt;/SPAN&gt; Industry, fyear;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN&gt;&lt;STRONG&gt;sort&lt;/STRONG&gt;&lt;/SPAN&gt; noduplicates&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;by&lt;/SPAN&gt; Industry fyear;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;where&lt;/SPAN&gt; ind_residual ne &lt;SPAN&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/SPAN&gt;;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2017 23:01:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Predicted-value-and-residual-value-for-each-SIC-Year/m-p/386837#M20144</guid>
      <dc:creator>HannahEH</dc:creator>
      <dc:date>2017-08-09T23:01:06Z</dc:date>
    </item>
  </channel>
</rss>

