<?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: Creating a dummy variable - assigning &amp;quot;1&amp;quot; to previous winners &amp;quot;0&amp;quot; to previous losers in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-dummy-variable-assigning-quot-1-quot-to-previous/m-p/186461#M303878</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;"&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;The company which earnings change is higher in the last year should receive "1"&lt;/SPAN&gt; "&lt;/P&gt;&lt;P&gt;Don't understand what you mean. what is change , how do you calculate it ? What is your output ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 20 Apr 2014 02:48:55 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2014-04-20T02:48:55Z</dc:date>
    <item>
      <title>Creating a dummy variable - assigning "1" to previous winners "0" to previous losers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-dummy-variable-assigning-quot-1-quot-to-previous/m-p/186458#M303875</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I operate with estimates of annual earnings data (panel data). I have&lt;/P&gt;&lt;P&gt;company, forecaster, time, forecast, earnings realizations&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;DATA TEST;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;INPUT company$ scenario year earnings_Poject realized;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;cards;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;A 1 1995 10 9&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;A 2 1995 4 9&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;A 1 1996 8 7&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;A 2 1996 5 7&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;A 1 1997 11 12&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;A 2 1997 10 12&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;B 1 1995 20 22&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;B 2 1995 17 22&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;B 1 1996 19 20&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;B 2 1996 26 20&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;B 1 1997 29 25&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;B 2 1997 23 25&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I wanted to assign a dummy variable to the observations. The company which earnings change is higher in the last year should receive "1". And so for each year.&lt;/P&gt;&lt;P&gt;E.g.&lt;/P&gt;&lt;P&gt;The case for 1995:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; font-family: verdana, arial, helvetica, sans-serif; background-color: #ffffcc;"&gt;A,1,1995,10,9 &amp;lt;- in 1996 gets "1"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; font-family: verdana, arial, helvetica, sans-serif; background-color: #ffffcc;"&gt;A&lt;/SPAN&gt;&lt;SPAN style="color: #222222; font-family: verdana, arial, helvetica, sans-serif; background-color: #ffffcc;"&gt;,2,1995,4,9 &amp;lt;- &lt;SPAN style="color: #222222; font-family: verdana, arial, helvetica, sans-serif; background-color: #ffffcc;"&gt;in 1996&lt;/SPAN&gt; gets "0"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; font-family: verdana, arial, helvetica, sans-serif; background-color: #ffffcc;"&gt;B,1,&lt;/SPAN&gt;&lt;SPAN style="color: #222222; font-family: verdana, arial, helvetica, sans-serif; background-color: #ffffcc;"&gt;1995&lt;/SPAN&gt;&lt;SPAN style="color: #222222; font-family: verdana, arial, helvetica, sans-serif; background-color: #ffffcc;"&gt;,20,22 &lt;SPAN style="color: #222222; font-family: verdana, arial, helvetica, sans-serif; background-color: #ffffcc;"&gt;&amp;lt;- &lt;SPAN style="color: #222222; font-family: verdana, arial, helvetica, sans-serif; background-color: #ffffcc;"&gt;in 1996&lt;/SPAN&gt; gets "1"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; font-family: verdana, arial, helvetica, sans-serif; background-color: #ffffcc;"&gt;B,2,1995,17,22 &lt;SPAN style="color: #222222; font-family: verdana, arial, helvetica, sans-serif; background-color: #ffffcc;"&gt;&amp;lt;- &lt;SPAN style="color: #222222; font-family: verdana, arial, helvetica, sans-serif; background-color: #ffffcc;"&gt;in 1996&lt;/SPAN&gt; &lt;SPAN style="color: #222222; font-family: verdana, arial, helvetica, sans-serif; background-color: #ffffcc;"&gt;gets "0"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and so on for each year...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would appreciate any help as the issue gives me only sleepless nights...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Apr 2014 15:36:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-dummy-variable-assigning-quot-1-quot-to-previous/m-p/186458#M303875</guid>
      <dc:creator>MattvanPallen</dc:creator>
      <dc:date>2014-04-19T15:36:35Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a dummy variable - assigning "1" to previous winners "0" to previous losers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-dummy-variable-assigning-quot-1-quot-to-previous/m-p/186459#M303876</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Again!&lt;/P&gt;&lt;P&gt;I have been fighting with this problem during the whole day.&lt;/P&gt;&lt;P&gt;I created an additional table with upper and lower quartiles for earnings of companies through the years.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="6045" alt="Capture.JPG" class="jive-image jiveImage" src="https://communities.sas.com/legacyfs/online/6045_Capture.JPG" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I would like create a dummy variable in the original data which would give "1" if the earnings fall within the upper quartile and "0" if earnigns of a company fall within the lower one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it will be easier to understand.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Apr 2014 21:18:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-dummy-variable-assigning-quot-1-quot-to-previous/m-p/186459#M303876</guid>
      <dc:creator>MattvanPallen</dc:creator>
      <dc:date>2014-04-19T21:18:26Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a dummy variable - assigning "1" to previous winners "0" to previous losers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-dummy-variable-assigning-quot-1-quot-to-previous/m-p/186460#M303877</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In the first part of your question what is your approach when there is a tie between the accuracy of the projections?&amp;nbsp; &lt;/P&gt;&lt;P&gt;In the second part of your question what is your approach when the change in earnings year on year is in the middle 2 quartiles? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Richard&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 20 Apr 2014 01:51:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-dummy-variable-assigning-quot-1-quot-to-previous/m-p/186460#M303877</guid>
      <dc:creator>RichardinOz</dc:creator>
      <dc:date>2014-04-20T01:51:17Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a dummy variable - assigning "1" to previous winners "0" to previous losers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-dummy-variable-assigning-quot-1-quot-to-previous/m-p/186461#M303878</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;"&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;The company which earnings change is higher in the last year should receive "1"&lt;/SPAN&gt; "&lt;/P&gt;&lt;P&gt;Don't understand what you mean. what is change , how do you calculate it ? What is your output ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 20 Apr 2014 02:48:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-dummy-variable-assigning-quot-1-quot-to-previous/m-p/186461#M303878</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-04-20T02:48:55Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a dummy variable - assigning "1" to previous winners "0" to previous losers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-dummy-variable-assigning-quot-1-quot-to-previous/m-p/186462#M303879</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@&lt;SPAN style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;STRONG&gt;&lt;A _jive_internal="true" class="jiveTT-hover-user jive-username-link" data-avatarid="-1" data-externalid="" data-presence="null" data-userid="809684" data-username="RichardinOz" href="https://communities.sas.com/people/RichardinOz" id="jive-80968413356133457994711" style="padding: 0 3px 0 0; font-weight: inherit; font-style: inherit; font-size: 1.1em; font-family: inherit; color: #0e66ba;"&gt;RichardinOz&lt;/A&gt; and @ &lt;STRONG style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;A _jive_internal="true" class="jiveTT-hover-user jive-username-link" data-avatarid="1075" data-externalid="" data-presence="null" data-userid="645292" data-username="Ksharp" href="https://communities.sas.com/people/Ksharp" id="jive-64529213361541988806711" style="padding: 0 3px 0 0; font-weight: inherit; font-style: inherit; font-size: 1.1em; font-family: inherit; color: #0e66ba;"&gt;Ksharp&lt;/A&gt; &lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your responses.&lt;/P&gt;&lt;P&gt;You are right, sorry for my imprecision.&lt;/P&gt;&lt;P&gt;Lets create two, separate dummies.&lt;/P&gt;&lt;P&gt;UPER and LOWER.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to compare the earnings of each company in the each year. &lt;/P&gt;&lt;P&gt;I computed the quartiles of earnigns for each company in the given year in the separate table as posted above.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Every company which will have earnings in the period t-1 in upper quartile will gain "1" in period t in the new column UPER.&lt;/P&gt;&lt;P&gt;Vice versa for the "losers" and lower quartile. Loser then in column LOWE appears "1"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I computed the quartiles in the separate table as posted above.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can I somehow use the table as role model for classification?&lt;/P&gt;&lt;P&gt;In excel I would build up VLOOKUP and some logical columns.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I really don't know the whole POWER of SAS.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 20 Apr 2014 08:09:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-dummy-variable-assigning-quot-1-quot-to-previous/m-p/186462#M303879</guid>
      <dc:creator>MattvanPallen</dc:creator>
      <dc:date>2014-04-20T08:09:54Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a dummy variable - assigning "1" to previous winners "0" to previous losers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-dummy-variable-assigning-quot-1-quot-to-previous/m-p/186463#M303880</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If I understand what you mean.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;
DATA TEST;
INPUT company$ scenario year earnings_Poject realized;
cards;
A 1 1995 10 9
A 2 1995 4 9
A 1 1996 8 7
A 2 1996 5 7
A 1 1997 11 12
A 2 1997 10 12
B 1 1995 20 22
B 2 1995 17 22
B 1 1996 19 20
B 2 1996 26 20
B 1 1997 29 25
B 2 1997 23 25
;
run;
data x;
input year upper lower;
cards;
1995 0.53 -0.23
1996 0.45 -0.43
1997 0.32 -0.52
;
run;
data x;
 set x;
run;
proc sort data=test ;by year;run;
data temp;
 merge test x;
 by year;
run;
proc sort data=temp;by company&amp;nbsp; year scenario;run;

data want;
 set temp;
 if company=lag2(company) and (lag2(earnings_Poject)-earnings_Poject) gt upper then upper_f=1;
 if company=lag2(company) and . lt (lag2(earnings_Poject)-earnings_Poject) lt lower then lower_f=1;
run;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: xia keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 20 Apr 2014 09:25:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-dummy-variable-assigning-quot-1-quot-to-previous/m-p/186463#M303880</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-04-20T09:25:31Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a dummy variable - assigning "1" to previous winners "0" to previous losers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-dummy-variable-assigning-quot-1-quot-to-previous/m-p/186464#M303881</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@Ksharp&lt;/P&gt;&lt;P&gt;Many, many thanks for your help and interest!&lt;/P&gt;&lt;P&gt;I've implemented some changes but it does the trick! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 20 Apr 2014 20:43:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-dummy-variable-assigning-quot-1-quot-to-previous/m-p/186464#M303881</guid>
      <dc:creator>MattvanPallen</dc:creator>
      <dc:date>2014-04-20T20:43:57Z</dc:date>
    </item>
  </channel>
</rss>

