<?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 can I assign index dates at random to unexposed patients by incidence density sampling in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-can-I-assign-index-dates-at-random-to-unexposed-patients-by/m-p/639903#M190432</link>
    <description>Thank you so much it was really helpful.&lt;BR /&gt;&lt;BR /&gt;I have one more question&lt;BR /&gt;If I want to assign an exact date not only the year how can I make it ?</description>
    <pubDate>Tue, 14 Apr 2020 21:24:45 GMT</pubDate>
    <dc:creator>ALAA1</dc:creator>
    <dc:date>2020-04-14T21:24:45Z</dc:date>
    <item>
      <title>how can I assign index dates at random to unexposed patients by incidence density sampling</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-can-I-assign-index-dates-at-random-to-unexposed-patients-by/m-p/639379#M190213</link>
      <description>&lt;P&gt;I would like to know how can I assign index dates at random to unexposed patients by incidence density sampling from the distribution of index dates in the exposed cohort, any help is appreciated.&lt;/P&gt;&lt;P&gt;the following is the distribution of exposed group per year according to their index date;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;ID_YEAR&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;Frequency&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;Percent&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;2000&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;337&lt;/P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have an index date while the control group don't have an index date and I want to assign it to them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Sun, 12 Apr 2020 23:18:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-can-I-assign-index-dates-at-random-to-unexposed-patients-by/m-p/639379#M190213</guid>
      <dc:creator>ALAA1</dc:creator>
      <dc:date>2020-04-12T23:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: how can I assign index dates at random to unexposed patients by incidence density sampling</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-can-I-assign-index-dates-at-random-to-unexposed-patients-by/m-p/639399#M190227</link>
      <description>&lt;P&gt;Use the RAND function with the "table" distribution to generate the assignments:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data pct;
input ID_YEAR Frequency   Percent;
datalines;
2000    337 1.60
2001    445 2.11
2002    542 2.57
2003    715 3.39
2004    764 3.63
2005    873 4.14
2006    1099    5.22
2007    1080    5.13
2008    1274    6.05
2009    1483    7.04
2010    1608    7.63
2011    1729    8.21
2012    1749    8.30
2013    1989    9.44
2014    1834    8.71
2015    1647    7.82
2016    1214    5.76
2017    685 3.25
;

proc sql;
select percent/100 into :pct separated by ","
from pct;
select min(id_year) - 1 into :baseYear
from pct;
quit;

/* fake data */
data unexposed;
do id = 1 to 1000;
	output;
	end;
run;

data assigned;
call streaminit(97987976);
set unexposed;
assigned_id_year = &amp;amp;baseYear. + rand("table", &amp;amp;pct.);
run;

/* check unexposed frequencies */
proc freq data = assigned;
table assigned_id_year;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2020 03:58:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-can-I-assign-index-dates-at-random-to-unexposed-patients-by/m-p/639399#M190227</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-04-13T03:58:21Z</dc:date>
    </item>
    <item>
      <title>Re: how can I assign index dates at random to unexposed patients by incidence density sampling</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-can-I-assign-index-dates-at-random-to-unexposed-patients-by/m-p/639903#M190432</link>
      <description>Thank you so much it was really helpful.&lt;BR /&gt;&lt;BR /&gt;I have one more question&lt;BR /&gt;If I want to assign an exact date not only the year how can I make it ?</description>
      <pubDate>Tue, 14 Apr 2020 21:24:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-can-I-assign-index-dates-at-random-to-unexposed-patients-by/m-p/639903#M190432</guid>
      <dc:creator>ALAA1</dc:creator>
      <dc:date>2020-04-14T21:24:45Z</dc:date>
    </item>
    <item>
      <title>Re: how can I assign index dates at random to unexposed patients by incidence density sampling</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-can-I-assign-index-dates-at-random-to-unexposed-patients-by/m-p/639960#M190458</link>
      <description>&lt;P&gt;The method above could be adapted to dates instead of years but might become impractical if the number of dates is too large. I don't know how many arguments can be handled by the RAND function. How many distinct dates would you have?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 04:49:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-can-I-assign-index-dates-at-random-to-unexposed-patients-by/m-p/639960#M190458</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-04-15T04:49:59Z</dc:date>
    </item>
    <item>
      <title>Re: how can I assign index dates at random to unexposed patients by incidence density sampling</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-can-I-assign-index-dates-at-random-to-unexposed-patients-by/m-p/640586#M190848</link>
      <description>&lt;P&gt;actually I have used the same method but it gives me until May 2013!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 6479 dates from 1 Jan 2000 to 26 Sep 2017.&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Apr 2020 23:54:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-can-I-assign-index-dates-at-random-to-unexposed-patients-by/m-p/640586#M190848</guid>
      <dc:creator>ALAA1</dc:creator>
      <dc:date>2020-04-16T23:54:44Z</dc:date>
    </item>
    <item>
      <title>Re: how can I assign index dates at random to unexposed patients by incidence density sampling</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-can-I-assign-index-dates-at-random-to-unexposed-patients-by/m-p/640599#M190854</link>
      <description>&lt;P&gt;Hummm... The pct macro variable is limited to 32k characters. Now 32k / 6479 is less than 6 characters per probability value, including a comma and a decimal point... I suspect that the list of probability values was truncated, which is why you didn't get the full range of dates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would it be acceptable to reduce the time resolution a bit, to say, weeks, months or even quarters? Hint: use functions intck and intnx to deal with such time intervals.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2020 02:39:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-can-I-assign-index-dates-at-random-to-unexposed-patients-by/m-p/640599#M190854</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-04-17T02:39:03Z</dc:date>
    </item>
  </channel>
</rss>

