<?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: COMPLEX PROBLEM: How do I compute relative experience in firm and with customers? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/COMPLEX-PROBLEM-How-do-I-compute-relative-experience-in-firm-and/m-p/244260#M45492</link>
    <description>&lt;P&gt;Thank you very much!!!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 18 Jan 2016 17:56:52 GMT</pubDate>
    <dc:creator>Andr</dc:creator>
    <dc:date>2016-01-18T17:56:52Z</dc:date>
    <item>
      <title>COMPLEX PROBLEM: How do I compute relative experience in firm and with customers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/COMPLEX-PROBLEM-How-do-I-compute-relative-experience-in-firm-and/m-p/243487#M45274</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;I am new to SAS and for my univerity project, I have a big set of data with many obsevations and variables and I need to create some new variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA&amp;amp;colon; I have a database of anayst forecasts, dates on which the forecast was published and firms to which the forecast was related.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example. Analyst 234 forecasted on 01May90 that firm 234 will have a profit of 500USD.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I need to compute: For each observation, I need to compute two new variables relative experience and relative firm experience.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Relative firm experience is computed as the number of years the analyst has been in the database at the time he published the particular forecast (time in full years since the first forecast of this analyst in the database till this forecast) minus the average experience of all all analyst who submited a forecast for this firm in this year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Secondly, I have to compute the firm specific experience. That is virtually the same, but I need to use&amp;nbsp;the number of years since the first forecast of the particular analyst for a particular firm (meaning time in full years since the first forecast of this analyst for this firm) again minus the average firm specific experience of all&amp;nbsp;analysts who submited a forecast for&amp;nbsp;that same firm in the same year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried many approaches but since I am not really familliar with SAS, I could't find a way to compute it and I would be really greatful for your help.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2016 15:42:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/COMPLEX-PROBLEM-How-do-I-compute-relative-experience-in-firm-and/m-p/243487#M45274</guid>
      <dc:creator>Andr</dc:creator>
      <dc:date>2016-01-14T15:42:49Z</dc:date>
    </item>
    <item>
      <title>Re: COMPLEX PROBLEM: How do I compute relative experience in firm and with customers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/COMPLEX-PROBLEM-How-do-I-compute-relative-experience-in-firm-and/m-p/243489#M45276</link>
      <description>&lt;P&gt;Please post some sample data with your expected output. If your variables are being calculated in a single row it's a relatively straightforward problem, but hard &amp;nbsp;to see or explain without data.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2016 15:48:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/COMPLEX-PROBLEM-How-do-I-compute-relative-experience-in-firm-and/m-p/243489#M45276</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-14T15:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: COMPLEX PROBLEM: How do I compute relative experience in firm and with customers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/COMPLEX-PROBLEM-How-do-I-compute-relative-experience-in-firm-and/m-p/243490#M45277</link>
      <description>&lt;P&gt;Firstly, what is this "DATA&amp;amp;colon" - I have noticed this in a quite a few posts recently. &amp;nbsp;&amp;lt;- ignore this, its a forum bug&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For your problem, can you provide some sample test data - in the form of a datastep, and what you want the output to look like. &amp;nbsp;Its easier to write code if it can be run.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2016 16:43:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/COMPLEX-PROBLEM-How-do-I-compute-relative-experience-in-firm-and/m-p/243490#M45277</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-01-14T16:43:40Z</dc:date>
    </item>
    <item>
      <title>Re: COMPLEX PROBLEM: How do I compute relative experience in firm and with customers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/COMPLEX-PROBLEM-How-do-I-compute-relative-experience-in-firm-and/m-p/243513#M45283</link>
      <description>&lt;P&gt;OK, a simplified example of the data could look like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;***DATA STEP TO CREATE LABS; DATA forecasts;
LENGTH Forecast $ 6;
INFORMAT FDATE MMDDYY10.;
INFILE DATALINES MISSOVER; 
INPUT ANALYST FIRM FORECAST FDATE;
FORMAT DATE MMDDYY10.;
DATALINES;
01 23 4 01/03/1995
01 23 7 04/04/1997
01 24 400 03/04/1993
01 24 450 03/04/2000
01 24 300 11/05/2001
02 23 20 11/03/1994
02 23 2 01/03/1995
02 23 8 05/04/1997
02 24 420 04/04/1991
02 24 430 06/04/2000
02 24 310 07/05/2001
03 23 21 11/03/1992
03 23 5 01/03/1995
03 23 6 05/04/1997
03 24 420 04/04/1995
03 24 430 06/04/1998
03 24 310 06/05/2004&lt;BR /&gt;04 24 20 03/06/2007&lt;BR /&gt;04 24 24 12/12/2010
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;An example for relative general experience for the second line would be comuted like this: Analyst 01 submited his fist forecast in 1993 and therefore has been forecastin for 1993-1997 five years including the first one and has five&amp;nbsp;years of general experience. At the same time, the oldest forecast for firm 23 was in 1995, therefore he has 3 years of firm specific experience.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to relate them to the other forecast. In 1997 also analysts 02 and 03 have submitted a forecast for firm 23. Analyst 04 hasn't, so I ignore him.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Their general experience (time form their first forecast in the dataset) is 1997-1991 + 1 = 7 years for analyst 02 and 1997-1992 + 1 = 6 for analyst 03. The average of all analysts is (5+7+6)/3=6 years and the relative general experience of analyst 01 is 5-6=-1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Their firm specific&amp;nbsp;experiences (time form their first forecast for firm 23 in the dataset) are 1997-1994 +1 = 4 for analyst 02 and 1997-1992 +1= 6 for analyst 03. The average of all analysts who submited a forecast for this firm in 1997 is (3+4+6)/3=4,33 and analyst 01 therefore has -1,33 years of relative firm specific experience.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope I explained it clear enough and you will be able to help me further. Thank you very much in advance!&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;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2016 16:54:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/COMPLEX-PROBLEM-How-do-I-compute-relative-experience-in-firm-and/m-p/243513#M45283</guid>
      <dc:creator>Andr</dc:creator>
      <dc:date>2016-01-14T16:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: COMPLEX PROBLEM: How do I compute relative experience in firm and with customers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/COMPLEX-PROBLEM-How-do-I-compute-relative-experience-in-firm-and/m-p/243521#M45286</link>
      <description>&lt;P&gt;May have been a paste error but there isn't any explicit data for analyst 04 unless that is in the last line.&lt;/P&gt;
&lt;P&gt;&amp;lt;Got it, not space between year and analyst&amp;gt;&lt;/P&gt;
&lt;P&gt;However you say&lt;/P&gt;
&lt;P&gt;Analyst 01 submited his fist forecast in 1993 and therefore has been forecastin for 1993-1997 five years including the first one and has five&amp;nbsp;years of general experience. At the same time, the oldest forecast for firm 23 was in 1995, therefore he has 3 years of firm specific experience.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But analyst 1 example shows first forecast in 1993 and last in 2001, not 1997, which would be 9 years. Unless there's another rule (or did you add data to an already existing example text?)&lt;/P&gt;
&lt;P&gt;Similar analyst 2 has forecasts from 1991-2001 not 1991 to 1997 as calculated in your example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2016 17:56:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/COMPLEX-PROBLEM-How-do-I-compute-relative-experience-in-firm-and/m-p/243521#M45286</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-01-14T17:56:24Z</dc:date>
    </item>
    <item>
      <title>Re: COMPLEX PROBLEM: How do I compute relative experience in firm and with customers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/COMPLEX-PROBLEM-How-do-I-compute-relative-experience-in-firm-and/m-p/243527#M45288</link>
      <description>&lt;P&gt;Here it is:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;***DATA STEP TO CREATE LABS; DATA forecasts;
LENGTH Forecast $ 6;
INFORMAT FDATE MMDDYY10.;
INFILE DATALINES MISSOVER; 
INPUT ANALYST FIRM FORECAST FDATE;
FORMAT DATE MMDDYY10.;
DATALINES;
01 23 4 01/03/1995
01 23 7 04/04/1997
01 24 400 03/04/1993
01 24 450 03/04/2000
01 24 300 11/05/2001
02 23 20 11/03/1994
02 23 2 01/03/1995
02 23 8 05/04/1997
02 24 420 04/04/1991
02 24 430 06/04/2000
02 24 310 07/05/2001
03 23 21 11/03/1992
03 23 5 01/03/1995
03 23 6 05/04/1997
03 24 420 04/04/1995
03 24 430 06/04/1998
03 24 310 06/05/2004
04 24 20 03/06/2007
04 24 24 12/12/2010
04 24 26 11/01/2011
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Jan 2016 17:50:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/COMPLEX-PROBLEM-How-do-I-compute-relative-experience-in-firm-and/m-p/243527#M45288</guid>
      <dc:creator>Andr</dc:creator>
      <dc:date>2016-01-14T17:50:48Z</dc:date>
    </item>
    <item>
      <title>Re: COMPLEX PROBLEM: How do I compute relative experience in firm and with customers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/COMPLEX-PROBLEM-How-do-I-compute-relative-experience-in-firm-and/m-p/244173#M45477</link>
      <description>&lt;P&gt;Any ideas, please?&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 08:31:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/COMPLEX-PROBLEM-How-do-I-compute-relative-experience-in-firm-and/m-p/244173#M45477</guid>
      <dc:creator>Andr</dc:creator>
      <dc:date>2016-01-18T08:31:09Z</dc:date>
    </item>
    <item>
      <title>Re: COMPLEX PROBLEM: How do I compute relative experience in firm and with customers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/COMPLEX-PROBLEM-How-do-I-compute-relative-experience-in-firm-and/m-p/244230#M45486</link>
      <description>&lt;P&gt;Been in meetings most of the day. &amp;nbsp;This code merges on min dates for the various groups, you can use datediff function on these versus the main date to find how many years in each section, then run a sum of them per groups:&lt;/P&gt;
&lt;PRE&gt;data have;&lt;BR /&gt; length forecast $ 6;&lt;BR /&gt; informat fdate mmddyy10.;&lt;BR /&gt; infile datalines missover; &lt;BR /&gt; input analyst firm forecast fdate;&lt;BR /&gt; format fdate mmddyy10.;&lt;BR /&gt;datalines;&lt;BR /&gt;01 23 4 01/03/1995&lt;BR /&gt;01 23 7 04/04/1997&lt;BR /&gt;01 24 400 03/04/1993&lt;BR /&gt;01 24 450 03/04/2000&lt;BR /&gt;01 24 300 11/05/2001&lt;BR /&gt;02 23 20 11/03/1994&lt;BR /&gt;02 23 2 01/03/1995&lt;BR /&gt;02 23 8 05/04/1997&lt;BR /&gt;02 24 420 04/04/1991&lt;BR /&gt;02 24 430 06/04/2000&lt;BR /&gt;02 24 310 07/05/2001&lt;BR /&gt;03 23 21 11/03/1992&lt;BR /&gt;03 23 5 01/03/1995&lt;BR /&gt;03 23 6 05/04/1997&lt;BR /&gt;03 24 420 04/04/1995&lt;BR /&gt;03 24 430 06/04/1998&lt;BR /&gt;03 24 310 06/05/2004&lt;BR /&gt;04 24 20 03/06/2007&lt;BR /&gt;04 24 24 12/12/2010&lt;BR /&gt;04 24 26 11/01/2011&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;/* Get min date per anlyst, firm, anlyst/firm */&lt;BR /&gt;proc sql;&lt;BR /&gt; create table MIN_ANALYST as&lt;BR /&gt; select ANALYST,min(FDATE) as MIN_FDATE1&lt;BR /&gt; from HAVE&lt;BR /&gt; group by ANALYST;&lt;BR /&gt; create table MIN_FIRM as&lt;BR /&gt; select FIRM,min(FDATE) as MIN_FDATE2&lt;BR /&gt; from HAVE&lt;BR /&gt; group by FIRM;&lt;BR /&gt; create table MIN_FIRM_ANALYST as&lt;BR /&gt; select FIRM,ANALYST,min(FDATE) as MIN_FDATE3&lt;BR /&gt; from HAVE&lt;BR /&gt; group by FIRM,ANALYST;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;/* Add these dates to main dataset */&lt;BR /&gt;proc sql;&lt;BR /&gt; create table INTER as&lt;BR /&gt; select A.*,&lt;BR /&gt; B.MIN_FDATE1 format=date9.,&lt;BR /&gt; C.MIN_FDATE2 format=date9.,&lt;BR /&gt; D.MIN_FDATE3 format=date9.,&lt;BR /&gt; datdif(B.MIN_FDATE1,A.FDATE,"ACT/ACT") / 365 as YRS1,&lt;BR /&gt; datdif(C.MIN_FDATE2,A.FDATE,"ACT/ACT") / 365 as YRS2,&lt;BR /&gt; datdif(D.MIN_FDATE3,A.FDATE,"ACT/ACT") / 365 as YRS3&lt;BR /&gt;&lt;BR /&gt; from HAVE A&lt;BR /&gt; left join MIN_ANALYST B&lt;BR /&gt; on A.ANALYST=B.ANALYST &lt;BR /&gt; left join MIN_FIRM C&lt;BR /&gt; on A.FIRM=C.FIRM&lt;BR /&gt; left join MIN_FIRM_ANALYST D&lt;BR /&gt; on A.ANALYST=D.ANALYST and A.FIRM=D.FIRM;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;/* So analyst years is */&lt;BR /&gt;proc sql;&lt;BR /&gt; create table WANT1 as&lt;BR /&gt; select ANALYST,sum(YRS1) as RESULT&lt;BR /&gt; from INTER&lt;BR /&gt; group by ANALYST;&lt;BR /&gt;quit;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Jan 2016 14:58:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/COMPLEX-PROBLEM-How-do-I-compute-relative-experience-in-firm-and/m-p/244230#M45486</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-01-18T14:58:58Z</dc:date>
    </item>
    <item>
      <title>Re: COMPLEX PROBLEM: How do I compute relative experience in firm and with customers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/COMPLEX-PROBLEM-How-do-I-compute-relative-experience-in-firm-and/m-p/244260#M45492</link>
      <description>&lt;P&gt;Thank you very much!!!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 17:56:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/COMPLEX-PROBLEM-How-do-I-compute-relative-experience-in-firm-and/m-p/244260#M45492</guid>
      <dc:creator>Andr</dc:creator>
      <dc:date>2016-01-18T17:56:52Z</dc:date>
    </item>
  </channel>
</rss>

