<?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 random dates from a list of firm-years in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/random-dates-from-a-list-of-firm-years/m-p/564628#M158400</link>
    <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please help me in coming out with random years from a list of firm-years provided below (panel dataset):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Firm Years&lt;/P&gt;&lt;P&gt;A 2010&lt;/P&gt;&lt;P&gt;A 2011&lt;/P&gt;&lt;P&gt;A 2012&lt;/P&gt;&lt;P&gt;A 2013&lt;/P&gt;&lt;P&gt;A 2014&lt;/P&gt;&lt;P&gt;B 2009&lt;/P&gt;&lt;P&gt;B 2010&lt;/P&gt;&lt;P&gt;B 2011&lt;/P&gt;&lt;P&gt;B 2012&lt;/P&gt;&lt;P&gt;B 2013&lt;/P&gt;&lt;P&gt;B 2014&lt;/P&gt;&lt;P&gt;B 2015&lt;/P&gt;&lt;P&gt;C 2013&lt;/P&gt;&lt;P&gt;C 2014&lt;/P&gt;&lt;P&gt;C 2015&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From the list, I want to come up with random years from the list of years (grouping by firms). For instance, firm A random year should be from 2010 to 2014. Likewise, for firm B, it should be from 2009 to 2015.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;</description>
    <pubDate>Sat, 08 Jun 2019 06:13:21 GMT</pubDate>
    <dc:creator>amanjot_42</dc:creator>
    <dc:date>2019-06-08T06:13:21Z</dc:date>
    <item>
      <title>random dates from a list of firm-years</title>
      <link>https://communities.sas.com/t5/SAS-Programming/random-dates-from-a-list-of-firm-years/m-p/564628#M158400</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please help me in coming out with random years from a list of firm-years provided below (panel dataset):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Firm Years&lt;/P&gt;&lt;P&gt;A 2010&lt;/P&gt;&lt;P&gt;A 2011&lt;/P&gt;&lt;P&gt;A 2012&lt;/P&gt;&lt;P&gt;A 2013&lt;/P&gt;&lt;P&gt;A 2014&lt;/P&gt;&lt;P&gt;B 2009&lt;/P&gt;&lt;P&gt;B 2010&lt;/P&gt;&lt;P&gt;B 2011&lt;/P&gt;&lt;P&gt;B 2012&lt;/P&gt;&lt;P&gt;B 2013&lt;/P&gt;&lt;P&gt;B 2014&lt;/P&gt;&lt;P&gt;B 2015&lt;/P&gt;&lt;P&gt;C 2013&lt;/P&gt;&lt;P&gt;C 2014&lt;/P&gt;&lt;P&gt;C 2015&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From the list, I want to come up with random years from the list of years (grouping by firms). For instance, firm A random year should be from 2010 to 2014. Likewise, for firm B, it should be from 2009 to 2015.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Sat, 08 Jun 2019 06:13:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/random-dates-from-a-list-of-firm-years/m-p/564628#M158400</guid>
      <dc:creator>amanjot_42</dc:creator>
      <dc:date>2019-06-08T06:13:21Z</dc:date>
    </item>
    <item>
      <title>Re: random dates from a list of firm-years</title>
      <link>https://communities.sas.com/t5/SAS-Programming/random-dates-from-a-list-of-firm-years/m-p/564635#M158402</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/198822"&gt;@amanjot_42&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC SURVEYSELECT (requires SAS/STAT) is the natural choice for this task:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Firm $ Years;
cards;
A 2010
A 2011
A 2012
A 2013
A 2014
B 2009
B 2010
B 2011
B 2012
B 2013
B 2014
B 2015
C 2013
C 2014
C 2015
;

proc surveyselect data=have method=srs n=1
                  seed=1618 out=want(keep=firm years);
strata firm;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The above statement selects n=1 observation randomly (srs=simple random sampling) from each of the strata (groups) defined by the values of FIRM (dataset HAVE should be sorted by FIRM) using the arbitrary positive integer 1618 as a seed to initialize the random number generator. Without the KEEP= option dataset WANT would contain two additional variables containing stratum sizes and selection probabilities.&lt;/P&gt;</description>
      <pubDate>Sat, 08 Jun 2019 08:09:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/random-dates-from-a-list-of-firm-years/m-p/564635#M158402</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-06-08T08:09:23Z</dc:date>
    </item>
    <item>
      <title>Re: random dates from a list of firm-years</title>
      <link>https://communities.sas.com/t5/SAS-Programming/random-dates-from-a-list-of-firm-years/m-p/564639#M158403</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/198822"&gt;@amanjot_42&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you don't have SAS/STAT licensed, you can simulate the function of Proc Surveyselect by adding a random key, sorting on Firm + random key and keeping the first occurence of each firm. Input is the data set provided by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp1; set have;
	rkey = ranuni(5);
run;

proc sort data=temp1;
	by Firm rkey;
run;

data want(drop=rkey); set temp1;
	by Firm;
	if first.Firm;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 08 Jun 2019 09:35:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/random-dates-from-a-list-of-firm-years/m-p/564639#M158403</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2019-06-08T09:35:42Z</dc:date>
    </item>
    <item>
      <title>Re: random dates from a list of firm-years</title>
      <link>https://communities.sas.com/t5/SAS-Programming/random-dates-from-a-list-of-firm-years/m-p/564640#M158404</link>
      <description>&lt;P&gt;If you don't have SAS/STAT licensed (but a recent version of Base SAS, e.g. 9.4M5)&amp;nbsp;&lt;EM&gt;and&lt;/EM&gt; you don't want to create or sort additional datasets, you can use this approach:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want(drop=i);
call streaminit(3141);
array y[50] _temporary_;
do i=1 by 1 until(last.firm);
  set have;
  by firm;
  y[i]=years;
end;
years=y[rand('integer',i)];
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This assumes that you have at most 50 observations (i.e. years) per firm. Increase the array dimension if that is not enough.&lt;/P&gt;</description>
      <pubDate>Sat, 08 Jun 2019 10:07:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/random-dates-from-a-list-of-firm-years/m-p/564640#M158404</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-06-08T10:07:32Z</dc:date>
    </item>
    <item>
      <title>Re: random dates from a list of firm-years</title>
      <link>https://communities.sas.com/t5/SAS-Programming/random-dates-from-a-list-of-firm-years/m-p/564646#M158405</link>
      <description>thanks,it worked well!&lt;BR /&gt;</description>
      <pubDate>Sat, 08 Jun 2019 12:09:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/random-dates-from-a-list-of-firm-years/m-p/564646#M158405</guid>
      <dc:creator>amanjot_42</dc:creator>
      <dc:date>2019-06-08T12:09:58Z</dc:date>
    </item>
  </channel>
</rss>

