<?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: Conditional Creation of New Dataset in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Conditional-Creation-of-New-Dataset/m-p/676876#M23743</link>
    <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;I want all WELL_API per ID where PHASE = 1 or 2 for any day between EXPOSURE_START and EXPOSURE_END.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I don't know what this means. Show me the output you want.&lt;/P&gt;</description>
    <pubDate>Fri, 14 Aug 2020 20:28:21 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-08-14T20:28:21Z</dc:date>
    <item>
      <title>Conditional Creation of New Dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Conditional-Creation-of-New-Dataset/m-p/676540#M23707</link>
      <description>&lt;P&gt;&lt;FONT size="2"&gt;I am stuck on how to create a new dataset based on a few variables I have now.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;What I have now is this:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="have.JPG" style="width: 482px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/48205i9A1ED651DA4A45EB/image-size/large?v=v2&amp;amp;px=999" role="button" title="have.JPG" alt="have.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input ID DATE :mmddyy10. PERIOD_01 PERIOD_02 PERIOD_03;
	FORMAT	ID z14.
			DATE mmddyy10.;
	datalines;
		01133244410000	01/03/2000	0	0	2
		02019220960000 	02/05/2000	0	2	2
		07167297020000  03/15/2000	2	2	2
		17067210480000  04/02/2000	0	0	0
	;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;I want the dataset structure below where DAY_01 = January 1, 2000 and DAY_N = December 31, 2015.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;And I want to incorporate two levels of coding:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;Level One:&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;DAY_01 - DAY_31 = PERIOD_01&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;DAY_32 - DAY_60 = PERIOD_02&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;DAY_61 - DAY_91 = PERIOD_03&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;Level Two:&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;All days prior to DATE = 0&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;The day corresponding to DATE = 1&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;All days after DATE = 1 until the first day that = 2&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="want.JPG" style="width: 444px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/48207iEDF6C66875497CE5/image-size/large?v=v2&amp;amp;px=999" role="button" title="want.JPG" alt="want.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	input ID DAY_01 DAY_02 DAY_03 DAY_04 DAY_N;
	FORMAT ID z14.;
	datalines;
		01133244410000 0 1 1 2 2
		02019220960000 0 0 1 2 2
		07167297020000 1 1 2 2 0
		17067210480000 1 2 0 0 0
	;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;FONT size="2"&gt;Any help would be really appreciated!&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Aug 2020 16:33:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Conditional-Creation-of-New-Dataset/m-p/676540#M23707</guid>
      <dc:creator>JJ_83</dc:creator>
      <dc:date>2020-08-13T16:33:55Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Creation of New Dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Conditional-Creation-of-New-Dataset/m-p/676549#M23709</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;I want the dataset structure below where DAY_01 = January 1, 2000 and DAY_N = December 31, 2015.&lt;/FONT&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;This is a truly horrible data structure, and one that will be a nightmare to program. Not only will programming be much easier if you leave the data in a long data set (rather than the proposed long data set), and then all of your calculations become simple. Maybe it works in Excel, but it doesn't work in SAS.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Aug 2020 16:52:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Conditional-Creation-of-New-Dataset/m-p/676549#M23709</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-08-13T16:52:31Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Creation of New Dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Conditional-Creation-of-New-Dataset/m-p/676553#M23712</link>
      <description>&lt;P&gt;This does the calculations in a few steps of code, creating a long data set. The similar wide data set would take lots more coding.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input ID $14. +1 DATE :mmddyy10. ;
	FORMAT DATE mmddyy10.;
	datalines;
01133244410000 01/03/2000
02019220960000 02/05/2000 
07167297020000 03/15/2000
17067210480000 04/02/2000
;

data want;
    set have;
    do all_dates='01JAN2000'd to '31DEC2015'd;
        if date&amp;gt;all_dates then indicator=2;
        else if date=all_dates then indicator=1;
        else if date&amp;lt;all_dates then indicator=0;
    	output;
	end;
	format all_dates mmddyyd10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Aug 2020 17:03:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Conditional-Creation-of-New-Dataset/m-p/676553#M23712</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-08-13T17:03:27Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Creation of New Dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Conditional-Creation-of-New-Dataset/m-p/676858#M23741</link>
      <description>&lt;P&gt;Hi Paige,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I see what you're saying about the benefits of a long vs wide dataset. Thank you for the suggestion!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have reorganized my dataset, and was hoping you could help with my last hurdle.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want all WELL_API per ID where PHASE = 1 or 2 for any day between EXPOSURE_START and EXPOSURE_END.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm stuck on how to do it with a long dataset.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input WELL_API $14. ID $11. +4 DAY :mmddyy10. EXPOSURE_START :mmddyy10. EXPOSURE_END :mmddyy10. PHASE $1.;
	format	DAY mmddyy10.
			EXPOSURE_START mmddyy10.
			EXPOSURE_END mmddyy10.;
	datalines;
		01133244410000 B1392272014 01/01/2010 01/01/2000 12/23/2014 0
		01133244410000 B1392272014 01/02/2010 01/01/2000 12/23/2014 1
		01133244410000 B1392272014 01/03/2010 01/01/2000 12/23/2014 2
		01133244410000 B1392272014 01/04/2010 01/01/2000 12/23/2014 3
		01133244410000 B1392272014 01/05/2010 01/01/2000 12/23/2014 0
	;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Aug 2020 19:38:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Conditional-Creation-of-New-Dataset/m-p/676858#M23741</guid>
      <dc:creator>JJ_83</dc:creator>
      <dc:date>2020-08-14T19:38:08Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Creation of New Dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Conditional-Creation-of-New-Dataset/m-p/676876#M23743</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;I want all WELL_API per ID where PHASE = 1 or 2 for any day between EXPOSURE_START and EXPOSURE_END.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I don't know what this means. Show me the output you want.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Aug 2020 20:28:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Conditional-Creation-of-New-Dataset/m-p/676876#M23743</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-08-14T20:28:21Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Creation of New Dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Conditional-Creation-of-New-Dataset/m-p/676888#M23745</link>
      <description>&lt;P&gt;Given this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="have.JPG" style="width: 570px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/48265i1B03597593D6F269/image-size/large?v=v2&amp;amp;px=999" role="button" title="have.JPG" alt="have.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input WELL_API $ ID $ DAY :mmddyy10. EXPOSURE_START :mmddyy10. EXPOSURE_END :mmddyy10. PHASE :best.;
	format	DAY mmddyy10.
			EXPOSURE_START mmddyy10.
			EXPOSURE_END mmddyy10.;
	datalines;
		01133244410000 B1392272014 01/01/2010 01/01/2000 01/05/2000 0
		01133244410000 B1392272014 01/02/2010 01/01/2000 01/05/2000 1
		01133244410000 B1392272014 01/03/2010 01/01/2000 01/05/2000 2
		01133244410000 B1392272014 01/04/2010 01/01/2000 01/05/2000 3
		01133244410000 B1392272014 01/05/2010 01/01/2000 01/05/2000 2
		01133244410000 B1392272014 01/06/2010 01/01/2000 01/05/2000 2
		01133244410000 B1392272014 01/07/2010 01/01/2000 01/05/2000 2
		01133244410000 B1392272014 01/08/2010 01/01/2000 01/05/2000 2
		01133244410000 B1392272014 01/09/2010 01/01/2000 01/05/2000 2
		01133244410000 B1392272014 01/10/2010 01/01/2000 01/05/2000 2
	;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I want this:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;All entries where&lt;UL&gt;&lt;LI&gt;Phase = (2 or 3)&lt;/LI&gt;&lt;LI&gt;Exposure_start &amp;lt;= Day &amp;lt;= Exposure end&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="want.JPG" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/48266i49920DF676678D4A/image-size/large?v=v2&amp;amp;px=999" role="button" title="want.JPG" alt="want.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	input WELL_API $ ID $ DAY :mmddyy10. EXPOSURE_START :mmddyy10. EXPOSURE_END :mmddyy10. PHASE best.;
	format	DAY mmddyy10.
			EXPOSURE_START mmddyy10.
			EXPOSURE_END mmddyy10.;
	datalines;
		01133244410000 B1392272014 01/03/2010 01/01/2000 01/05/2000 2
		01133244410000 B1392272014 01/04/2010 01/01/2000 01/05/2000 3
		01133244410000 B1392272014 01/05/2010 01/01/2000 01/05/2000 2
	;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Aug 2020 21:01:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Conditional-Creation-of-New-Dataset/m-p/676888#M23745</guid>
      <dc:creator>JJ_83</dc:creator>
      <dc:date>2020-08-14T21:01:30Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Creation of New Dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Conditional-Creation-of-New-Dataset/m-p/676893#M23746</link>
      <description>&lt;P&gt;I have assumed that the column DAY is actually days in year 2000 instead of days in year 2010. Otherwise your output data set does not agree with your words.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    where phase in (2,3) and exposure_start&amp;lt;=day&amp;lt;=exposure_end;    
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp; &lt;/P&gt;</description>
      <pubDate>Fri, 14 Aug 2020 21:16:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Conditional-Creation-of-New-Dataset/m-p/676893#M23746</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-08-14T21:16:15Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Creation of New Dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Conditional-Creation-of-New-Dataset/m-p/676894#M23747</link>
      <description>&lt;P&gt;The day variable refers to days, I just truncated it to the first 5 days in 2000.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code is not working for me.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Aug 2020 21:17:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Conditional-Creation-of-New-Dataset/m-p/676894#M23747</guid>
      <dc:creator>JJ_83</dc:creator>
      <dc:date>2020-08-14T21:17:26Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Creation of New Dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Conditional-Creation-of-New-Dataset/m-p/676895#M23748</link>
      <description>&lt;P&gt;Please do not ever say "the code is not working for me" and then provide no additional information. We cannot help you if all you say is "the code is not working for me".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Show us the log, by pasting the log as text into the window that appears when you click on &amp;lt;/&amp;gt;. Show us the ENTIRE log of the DATA step, do not chop anything out.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You also need to address how day can be in year 2010 but somehow winds up in the output.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Aug 2020 21:23:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Conditional-Creation-of-New-Dataset/m-p/676895#M23748</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-08-14T21:23:15Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Creation of New Dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Conditional-Creation-of-New-Dataset/m-p/676901#M23749</link>
      <description>&lt;P&gt;Ahh I see, there was a typo in the day variable. I wanted the first 5 days in 2000, but I put the first 5 days in 2010.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Everything works great now, thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 14 Aug 2020 21:52:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Conditional-Creation-of-New-Dataset/m-p/676901#M23749</guid>
      <dc:creator>JJ_83</dc:creator>
      <dc:date>2020-08-14T21:52:38Z</dc:date>
    </item>
  </channel>
</rss>

