<?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: Create dummy variable dependent on time interval in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Create-dummy-variable-dependent-on-time-interval/m-p/545655#M16797</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/267446"&gt;@YoLohse&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SQL syntax is often quite useful for such use cases.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc sql;
/*  create table want as*/
    select 
      *,
      case
        when gender='0' then ' '
        when gender='1' and (select count(*) 
                              from WORK.ALLDATA I 
                              where i.gender='0' 
                              and i.RunDate=o.RunDate 
                              and o.RunTime+20&amp;gt;=i.RunTime and o.RunTime-30&amp;lt;=i.RunTime
                              ) &amp;gt; 0 
                        then '1'
        else '0'
        end
      as finish_flg
    from WORK.ALLDATA O
    ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 24 Mar 2019 23:31:48 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2019-03-24T23:31:48Z</dc:date>
    <item>
      <title>Create dummy variable dependent on time interval</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Create-dummy-variable-dependent-on-time-interval/m-p/545587#M16790</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I have a dataset of men (gender =1) and women (gender=0) running 5k runs. I want a dummy that is 1 if a man finished 20 seconds before or 30 seconds after a woman, else 0. For women the dummy should just be empty. The 'RunTime' variable is in seconds.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WORK.ALLDATA;
  infile datalines dsd truncover;
  input RunDate:MMDDYY10. RunnerID:BEST. Gender:$1. Age:BEST. RunTime:BEST. Placement:BEST.;
  format RunDate MMDDYY10. RunnerID BEST. Age BEST. RunTime BEST. Placement BEST.;
  label RunDate="RunDate" RunnerID="RunnerID" Gender="Gender" Age="Age" RunTime="RunTime" Placement="Placement";
datalines;
10/22/2011 198111 1 39 1102 1
10/22/2011 33415 1 44 1134 2
10/22/2011 196982 1 44 1164 3
10/22/2011 92330 1 24 1182 4
10/22/2011 33809 1 59 1188 5
10/22/2011 79259 1 54 1190 6
10/22/2011 60226 1 59 1210 7
10/22/2011 32065 1 39 1224 8
10/22/2011 134140 1 54 1236 9
10/22/2011 37522 1 44 1247 10
10/22/2011 173019 1 49 1251 11
10/22/2011 186056 0 54 1257 12
10/22/2011 184284 1 34 1275 13
10/22/2011 43517 1 44 1277 14
10/22/2011 39169 1 39 1287 15
10/22/2011 90659 1 39 1346 16
10/22/2011 196665 1 24 1379 17
10/22/2011 36277 1 44 1392 18
10/22/2011 31453 1 49 1394 19
10/22/2011 89064 1 39 1399 20
;;;;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 24 Mar 2019 11:11:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Create-dummy-variable-dependent-on-time-interval/m-p/545587#M16790</guid>
      <dc:creator>YoLohse</dc:creator>
      <dc:date>2019-03-24T11:11:46Z</dc:date>
    </item>
    <item>
      <title>Re: Create dummy variable dependent on time interval</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Create-dummy-variable-dependent-on-time-interval/m-p/545590#M16791</link>
      <description>&lt;P&gt;To find if a man finished 30 seconds or less after a woman, you can use the LAG function. Examples are given at: &lt;A href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=n0l66p5oqex1f2n1quuopdvtcjqb.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=n0l66p5oqex1f2n1quuopdvtcjqb.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To find in a man finished 20 seconds or less before a woman, you will have to sort the data in reverse chronological order, and then use the LAG function again.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Mar 2019 12:01:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Create-dummy-variable-dependent-on-time-interval/m-p/545590#M16791</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-03-24T12:01:33Z</dc:date>
    </item>
    <item>
      <title>Re: Create dummy variable dependent on time interval</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Create-dummy-variable-dependent-on-time-interval/m-p/545599#M16794</link>
      <description>&lt;P&gt;Hi Paige&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your reply, I don't think I know SAS well enough to do that without some help to the coding part.&lt;/P&gt;&lt;P&gt;My immediate idea would be to make a dummy 'Behind Woman' (BW) that is 1 if a man's time is between 1-30 seconds slower than a woman's time. Then a dummy 'in Front of Woman' (FW) that is 1 if a man's time between 1-20 seconds faster than a woman's time.&lt;/P&gt;&lt;P&gt;At last I would make a 'Close To Woman' (CTW) dummy that is 1 if either FW or BW = 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't know how to keep the latest woman observation in front/behind a man's time to use it for comparison when creating the Dummies. I see you have linked the LAG-function but i don't see how it can be used. I have linked the code that I have written now that I think could do the trick if i could get the 'WRunTime' (closes't woman in front/ behind's time) and 'WRunDate' (same but for date). Hope you can help!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Sorterer til BW dummy */
proc sort 
data=DataAW; 
by RunDate RunTime; 
run;
/* Laver BW dummy */
data DataBW;
set DataAW;
If Gender= 1 and RunDate = WRundate and RunTime &amp;gt; WRunTime and RunTime &amp;lt; WRunTime+31 then BW = 1;
run;
/* Sorterer til FW dummy */
proc sort 
data=DataBW; 
by descending RunDate RunTime; 
run;
/* Laver FW dummy */
data DataFW;
set DataBW;
If Gender= 1 and RunDate = WRundate and RunTime &amp;lt; WRunTime and RunTime +21 &amp;gt; WRunTime then FW = 1; 
run;
/* Laver CTW dummy */
data DataCTW;
set DataFW;
If BW = 1 or FW = 1 then CTW = 1; 
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 24 Mar 2019 14:20:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Create-dummy-variable-dependent-on-time-interval/m-p/545599#M16794</guid>
      <dc:creator>YoLohse</dc:creator>
      <dc:date>2019-03-24T14:20:10Z</dc:date>
    </item>
    <item>
      <title>Re: Create dummy variable dependent on time interval</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Create-dummy-variable-dependent-on-time-interval/m-p/545609#M16795</link>
      <description>&lt;P&gt;&lt;SPAN class="token keyword" style="background-attachment: scroll; background-clip: border-box; background-color: #ffffff; background-image: none; background-origin: padding-box; background-position-x: 0%; background-position-y: 0%; background-repeat: repeat; background-size: auto; box-sizing: inherit; color: blue; font-family: Consolas,Monaco,&amp;amp;quot; andale mono&amp;amp;quot;,&amp;amp;quot;ubuntu mono&amp;amp;quot;,monospace; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;If&lt;/SPAN&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: black; direction: ltr; font-family: Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace; font-size: 1em; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.5; -ms-hyphens: none; orphans: 2; overflow-wrap: normal; text-align: left; text-decoration: none; text-indent: 0px; text-shadow: 0px 1px white; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-break: normal; word-spacing: normal;"&gt; Gender&lt;/SPAN&gt;&lt;SPAN class="token operator" style="box-sizing: inherit; color: #a67f59; font-family: Consolas,Monaco,&amp;amp;quot; andale mono&amp;amp;quot;,&amp;amp;quot;ubuntu mono&amp;amp;quot;,monospace; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token number" style="box-sizing: inherit; color: #008080; font-family: Consolas,Monaco,&amp;amp;quot; andale mono&amp;amp;quot;,&amp;amp;quot;ubuntu mono&amp;amp;quot;,monospace; font-size: 14px; font-style: normal; font-variant: normal; font-weight: bold; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: black; direction: ltr; font-family: Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace; font-size: 1em; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.5; -ms-hyphens: none; orphans: 2; overflow-wrap: normal; text-align: left; text-decoration: none; text-indent: 0px; text-shadow: 0px 1px white; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-break: normal; word-spacing: normal;"&gt; and RunDate &lt;/SPAN&gt;&lt;SPAN class="token operator" style="box-sizing: inherit; color: #a67f59; font-family: Consolas,Monaco,&amp;amp;quot; andale mono&amp;amp;quot;,&amp;amp;quot;ubuntu mono&amp;amp;quot;,monospace; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: black; direction: ltr; font-family: Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace; font-size: 1em; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.5; -ms-hyphens: none; orphans: 2; overflow-wrap: normal; text-align: left; text-decoration: none; text-indent: 0px; text-shadow: 0px 1px white; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-break: normal; word-spacing: normal;"&gt; WRundate and RunTime &lt;/SPAN&gt;&lt;SPAN class="token operator" style="box-sizing: inherit; color: #a67f59; font-family: Consolas,Monaco,&amp;amp;quot; andale mono&amp;amp;quot;,&amp;amp;quot;ubuntu mono&amp;amp;quot;,monospace; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: black; direction: ltr; font-family: Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace; font-size: 1em; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.5; -ms-hyphens: none; orphans: 2; overflow-wrap: normal; text-align: left; text-decoration: none; text-indent: 0px; text-shadow: 0px 1px white; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-break: normal; word-spacing: normal;"&gt; WRunTime and RunTime &lt;/SPAN&gt;&lt;SPAN class="token operator" style="box-sizing: inherit; color: #a67f59; font-family: Consolas,Monaco,&amp;amp;quot; andale mono&amp;amp;quot;,&amp;amp;quot;ubuntu mono&amp;amp;quot;,monospace; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: black; direction: ltr; font-family: Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace; font-size: 1em; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.5; -ms-hyphens: none; orphans: 2; overflow-wrap: normal; text-align: left; text-decoration: none; text-indent: 0px; text-shadow: 0px 1px white; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-break: normal; word-spacing: normal;"&gt; WRunTime&lt;/SPAN&gt;&lt;SPAN class="token operator" style="box-sizing: inherit; color: #a67f59; font-family: Consolas,Monaco,&amp;amp;quot; andale mono&amp;amp;quot;,&amp;amp;quot;ubuntu mono&amp;amp;quot;,monospace; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;+&lt;/SPAN&gt;&lt;SPAN class="token number" style="box-sizing: inherit; color: #008080; font-family: Consolas,Monaco,&amp;amp;quot; andale mono&amp;amp;quot;,&amp;amp;quot;ubuntu mono&amp;amp;quot;,monospace; font-size: 14px; font-style: normal; font-variant: normal; font-weight: bold; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;31&lt;/SPAN&gt; &lt;SPAN class="token keyword" style="background-attachment: scroll; background-clip: border-box; background-color: #ffffff; background-image: none; background-origin: padding-box; background-position-x: 0%; background-position-y: 0%; background-repeat: repeat; background-size: auto; box-sizing: inherit; color: blue; font-family: Consolas,Monaco,&amp;amp;quot; andale mono&amp;amp;quot;,&amp;amp;quot;ubuntu mono&amp;amp;quot;,monospace; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: black; direction: ltr; font-family: Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace; font-size: 1em; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.5; -ms-hyphens: none; orphans: 2; overflow-wrap: normal; text-align: left; text-decoration: none; text-indent: 0px; text-shadow: 0px 1px white; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-break: normal; word-spacing: normal;"&gt; BW &lt;/SPAN&gt;&lt;SPAN class="token operator" style="box-sizing: inherit; color: #a67f59; font-family: Consolas,Monaco,&amp;amp;quot; andale mono&amp;amp;quot;,&amp;amp;quot;ubuntu mono&amp;amp;quot;,monospace; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token number" style="box-sizing: inherit; color: #008080; font-family: Consolas,Monaco,&amp;amp;quot; andale mono&amp;amp;quot;,&amp;amp;quot;ubuntu mono&amp;amp;quot;,monospace; font-size: 14px; font-style: normal; font-variant: normal; font-weight: bold; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation" style="box-sizing: inherit; color: #999999; font-family: Consolas,Monaco,&amp;amp;quot; andale mono&amp;amp;quot;,&amp;amp;quot;ubuntu mono&amp;amp;quot;,monospace; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;;&lt;/SPAN&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: black; direction: ltr; font-family: Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace; font-size: 1em; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.5; -ms-hyphens: none; orphans: 2; overflow-wrap: normal; text-align: left; text-decoration: none; text-indent: 0px; text-shadow: 0px 1px white; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-break: normal; word-spacing: normal;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: black; direction: ltr; font-family: Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace; font-size: 1em; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.5; -ms-hyphens: none; orphans: 2; overflow-wrap: normal; text-align: left; text-decoration: none; text-indent: 0px; text-shadow: 0px 1px white; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-break: normal; word-spacing: normal;"&gt;where did wrundate and wruntime come from. you don't have those listed in the original data that you supplied.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: black; direction: ltr; font-family: Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace; font-size: 1em; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.5; -ms-hyphens: none; orphans: 2; overflow-wrap: normal; text-align: left; text-decoration: none; text-indent: 0px; text-shadow: 0px 1px white; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-break: normal; word-spacing: normal;"&gt;if there was a data step that assigned those values it would really help.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: black; direction: ltr; font-family: Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace; font-size: 1em; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.5; -ms-hyphens: none; orphans: 2; overflow-wrap: normal; text-align: left; text-decoration: none; text-indent: 0px; text-shadow: 0px 1px white; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-break: normal; word-spacing: normal;"&gt;Also the way you have the information being tested doesn't make logic since.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: black; direction: ltr; font-family: Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace; font-size: 1em; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.5; -ms-hyphens: none; orphans: 2; overflow-wrap: normal; text-align: left; text-decoration: none; text-indent: 0px; text-shadow: 0px 1px white; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-break: normal; word-spacing: normal;"&gt;Why are you touching the data so many times.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 24 Mar 2019 17:11:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Create-dummy-variable-dependent-on-time-interval/m-p/545609#M16795</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2019-03-24T17:11:21Z</dc:date>
    </item>
    <item>
      <title>Re: Create dummy variable dependent on time interval</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Create-dummy-variable-dependent-on-time-interval/m-p/545612#M16796</link>
      <description>&lt;P&gt;WRunDate and WRunTime are the variables I need help creating, the W standing for Woman. I don't know if those are needed or if my IF-Statement will would work even if I got those variables.&lt;/P&gt;&lt;P&gt;The reason my code probably looks very suboptimal, incorrect and messy to you is because I have almost no experience at coding in SAS. I have only used VBA coding which is where my syntax is from when I do guesses of code like I did here.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Mar 2019 17:30:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Create-dummy-variable-dependent-on-time-interval/m-p/545612#M16796</guid>
      <dc:creator>YoLohse</dc:creator>
      <dc:date>2019-03-24T17:30:07Z</dc:date>
    </item>
    <item>
      <title>Re: Create dummy variable dependent on time interval</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Create-dummy-variable-dependent-on-time-interval/m-p/545655#M16797</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/267446"&gt;@YoLohse&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SQL syntax is often quite useful for such use cases.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc sql;
/*  create table want as*/
    select 
      *,
      case
        when gender='0' then ' '
        when gender='1' and (select count(*) 
                              from WORK.ALLDATA I 
                              where i.gender='0' 
                              and i.RunDate=o.RunDate 
                              and o.RunTime+20&amp;gt;=i.RunTime and o.RunTime-30&amp;lt;=i.RunTime
                              ) &amp;gt; 0 
                        then '1'
        else '0'
        end
      as finish_flg
    from WORK.ALLDATA O
    ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 24 Mar 2019 23:31:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Create-dummy-variable-dependent-on-time-interval/m-p/545655#M16797</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-03-24T23:31:48Z</dc:date>
    </item>
  </channel>
</rss>

