<?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: Input/Output in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/496965#M131568</link>
    <description>&lt;P&gt;One way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;output;&lt;/P&gt;
&lt;P&gt;if start_date = '01dec2016'd then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;start_date = '01jul2017'd;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;end_date = '31jul2017'd;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
    <pubDate>Wed, 19 Sep 2018 13:43:15 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2018-09-19T13:43:15Z</dc:date>
    <item>
      <title>Input/Output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/496893#M131539</link>
      <description>&lt;P&gt;I have a dataset with variables Start_Date , End_Date, Price, and Unit. All the start dates begin at the first of the month and the end dates end on the last day of the month. In the existing data set the dates are for months in 2016. I would like to create new observations with the start date being 01JUL2017 and the end dates being 31JUL2017. These new July observations should have the same&amp;nbsp;data as those whose start date is 01DEC2016. Any suggestions on how to create these new observations? Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 11:07:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/496893#M131539</guid>
      <dc:creator>talzy7</dc:creator>
      <dc:date>2018-09-19T11:07:06Z</dc:date>
    </item>
    <item>
      <title>Re: Input/Output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/496905#M131542</link>
      <description>&lt;P&gt;Take a copy of&amp;nbsp;the data you want to copy, change it, add it back on.&amp;nbsp; Maybe something like (just a guess as you&amp;nbsp;&lt;U&gt;&lt;STRONG&gt;have not posted test data in the form of a datastep&lt;/STRONG&gt;&lt;/U&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;data extr;
  set have;
  where date &amp;gt;= "01dec2016"d;
  /* move dates 7 months forward, so dec becomes jul etc. */
  date=intnx('month',date,7);
run;

/* Add onto existing data */
data want;
  set have extr;
run;
&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Sep 2018 11:39:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/496905#M131542</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-19T11:39:37Z</dc:date>
    </item>
    <item>
      <title>Re: Input/Output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/496960#M131567</link>
      <description>can you please share the sample data?</description>
      <pubDate>Wed, 19 Sep 2018 13:28:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/496960#M131567</guid>
      <dc:creator>Vibcom</dc:creator>
      <dc:date>2018-09-19T13:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: Input/Output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/496965#M131568</link>
      <description>&lt;P&gt;One way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;output;&lt;/P&gt;
&lt;P&gt;if start_date = '01dec2016'd then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;start_date = '01jul2017'd;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;end_date = '31jul2017'd;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 13:43:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/496965#M131568</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-09-19T13:43:15Z</dc:date>
    </item>
    <item>
      <title>Re: Input/Output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/497054#M131619</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dataset.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/23384iD3E493B87403E665/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dataset.png" alt="dataset.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the first seven observations of my initial data set.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 16:37:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/497054#M131619</guid>
      <dc:creator>talzy7</dc:creator>
      <dc:date>2018-09-19T16:37:59Z</dc:date>
    </item>
    <item>
      <title>Re: Input/Output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/497055#M131620</link>
      <description>&lt;P&gt;Thank you!! This was very helpful!&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 16:38:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/497055#M131620</guid>
      <dc:creator>talzy7</dc:creator>
      <dc:date>2018-09-19T16:38:29Z</dc:date>
    </item>
    <item>
      <title>Re: Input/Output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/497058#M131623</link>
      <description>&lt;P&gt;Thank you!!&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 16:39:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/497058#M131623</guid>
      <dc:creator>talzy7</dc:creator>
      <dc:date>2018-09-19T16:39:23Z</dc:date>
    </item>
    <item>
      <title>Re: Input/Output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/497086#M131633</link>
      <description>&lt;P&gt;In my data step I am trying to create a new variable called Season which is Winter if start_date = '01DEC2016'd and is summer if start_date='01JUL2017'd. I tried the following in my data step but the season column is not filled.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;select (Start_Date);&lt;BR /&gt;when ('01DEC2016'd) do;&lt;BR /&gt;Season = 'Winter';&lt;BR /&gt;output work.extended;&lt;BR /&gt;end;&lt;BR /&gt;when ('01JUL2017'd) do;&lt;BR /&gt;Season = 'Summer';&lt;BR /&gt;output work.extended;&lt;BR /&gt;end;&lt;BR /&gt;otherwise do;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 19:25:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/497086#M131633</guid>
      <dc:creator>talzy7</dc:creator>
      <dc:date>2018-09-19T19:25:46Z</dc:date>
    </item>
    <item>
      <title>Re: Input/Output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/497090#M131636</link>
      <description>&lt;P&gt;You say you want to do something if the start date is July 1, 2016.&amp;nbsp; But your program never checks for the start date being July 1, 2016.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 19:00:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/497090#M131636</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-09-19T19:00:19Z</dc:date>
    </item>
    <item>
      <title>Re: Input/Output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/497098#M131638</link>
      <description>&lt;P&gt;Does select (Start_Date) and when not do this?&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 19:29:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/497098#M131638</guid>
      <dc:creator>talzy7</dc:creator>
      <dc:date>2018-09-19T19:29:12Z</dc:date>
    </item>
    <item>
      <title>Re: Input/Output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/497102#M131642</link>
      <description>&lt;P&gt;That will look at start_date.&amp;nbsp; But none of your WHEN clauses look for that particular date.&amp;nbsp; So nothing happens for that date.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 19:41:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/497102#M131642</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-09-19T19:41:45Z</dc:date>
    </item>
    <item>
      <title>Re: Input/Output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/497347#M131793</link>
      <description>&lt;P&gt;What is the best method to use to check for the date?&lt;/P&gt;</description>
      <pubDate>Thu, 20 Sep 2018 13:05:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/497347#M131793</guid>
      <dc:creator>talzy7</dc:creator>
      <dc:date>2018-09-20T13:05:50Z</dc:date>
    </item>
    <item>
      <title>Re: Input/Output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/497385#M131812</link>
      <description>&lt;P&gt;The method you are using is fine.&amp;nbsp; These particular WHEN statements just never check for the date that you are interested in.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's also not clear if you mean to add the OUTPUT statements, or whether they should just be omitted.&amp;nbsp; That depends on what you want the result to be.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Sep 2018 14:27:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/497385#M131812</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-09-20T14:27:58Z</dc:date>
    </item>
    <item>
      <title>Re: Input/Output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/497734#M132032</link>
      <description>&lt;P&gt;This is the data step I am currently trying:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data work.extended;&lt;BR /&gt;set prg.discount2016;&lt;BR /&gt;output;&lt;BR /&gt;where Start_Date = '01DEC2016'd;&lt;BR /&gt;if Start_Date = '01DEC2016'd then do;&lt;BR /&gt;Promotion = 'Holiday Bonus';&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;if Start_Date = '01DEC2016'd then do;&lt;BR /&gt;Start_Date = '01JUL2017'd;&lt;BR /&gt;End_Date = '31JUL2017'd;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;drop Unit_Sales_Price;&lt;/P&gt;&lt;P&gt;select (Start_Date);&lt;BR /&gt;when ('01DEC2016'd) do;&lt;BR /&gt;Season = 'Winter';&lt;BR /&gt;output work.extended;&lt;BR /&gt;end;&lt;BR /&gt;when ('01JUL2017'd) do;&lt;BR /&gt;Season = 'Summer';&lt;BR /&gt;output work.extended;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am still not understanding why it wont output the season if I explicitly say when ('01DEC2016'd) ?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 09:38:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/497734#M132032</guid>
      <dc:creator>talzy7</dc:creator>
      <dc:date>2018-09-21T09:38:31Z</dc:date>
    </item>
    <item>
      <title>Re: Input/Output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/497765#M132057</link>
      <description>&lt;P&gt;Your DATA step statements execute in order, from top to bottom.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Earlier statements change the start date from 01DEC2016 to 01JUL2017.&amp;nbsp; Those changes remain in effect, so when you later check for 01DEC2016 there is no match.&amp;nbsp; The value has been changed to 01JUL2017.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 11:32:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/497765#M132057</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-09-21T11:32:10Z</dc:date>
    </item>
    <item>
      <title>Re: Input/Output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/497773#M132065</link>
      <description>&lt;P&gt;Okay that makes sense. So I am assuming the following statement causes Start_Date to change to 01JUL2017:&lt;/P&gt;&lt;P&gt;if Start_Date = '01DEC2016'd then do;&lt;BR /&gt;Start_Date = '01JUL2017'd;&lt;BR /&gt;End_Date = '31JUL2017'd;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What method can be used so that 01DEC2016 is recognized as Winter and 01JUL2017 as summer without compromising the above statement? Thank you for all your help by the way.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 11:54:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/497773#M132065</guid>
      <dc:creator>talzy7</dc:creator>
      <dc:date>2018-09-21T11:54:53Z</dc:date>
    </item>
    <item>
      <title>Re: Input/Output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/497801#M132081</link>
      <description>&lt;P&gt;The smallest changes to the program would involve consolidating the calculations.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm making some assumptions on where I think you are headed.&amp;nbsp; For example, I think you want all the observations, not just those that satisfy the WHERE statement.&amp;nbsp; And I think you want 01DEC2016 output only once.&amp;nbsp; My best guess:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data work.extended;&lt;BR /&gt;set prg.discount2016;&lt;BR /&gt;if Start_Date = '01DEC2016'd then do;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;Promotion = 'Holiday Bonus';&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;Season = 'Winter';&lt;BR /&gt;&amp;nbsp; &amp;nbsp;output;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;Promotion = ' ';&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;Season = ' ';&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;Start_Date = '01JUL2017'd;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;End_Date = '31JUL2017'd;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;output;&lt;BR /&gt;end;&lt;/P&gt;
&lt;P&gt;else if start_date = '01DEC2016'd then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;season = 'Summer';&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;else output;&lt;BR /&gt;drop Unit_Sales_Price;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 12:57:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/497801#M132081</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-09-21T12:57:50Z</dc:date>
    </item>
    <item>
      <title>Re: Input/Output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/497872#M132127</link>
      <description>&lt;P&gt;Thanks. I included the where statement because I am only wanting to output the&amp;nbsp;01DEC2016 and 01JUL2017 observations. When I use the method described above only winter is shown not summer.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 15:35:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/497872#M132127</guid>
      <dc:creator>talzy7</dc:creator>
      <dc:date>2018-09-21T15:35:04Z</dc:date>
    </item>
    <item>
      <title>Re: Input/Output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/497874#M132128</link>
      <description>&lt;P&gt;OK, I know I was guessing a little at the desired results.&amp;nbsp; It's clear now (I think).&amp;nbsp; Here's a rewrite:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data work.extended;&lt;BR /&gt;set prg.discount2016;&lt;/P&gt;
&lt;P&gt;where Start_Date = '01DEC2016'd;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;Promotion = 'Holiday Bonus';&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;Season = 'Winter';&lt;BR /&gt;&amp;nbsp; &amp;nbsp;output;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;Promotion = ' ';&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;Start_Date = '01JUL2017'd;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;End_Date = '31JUL2017'd;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;season = 'Summer';&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;output;&lt;BR /&gt;drop Unit_Sales_Price;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 15:39:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/497874#M132128</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-09-21T15:39:42Z</dc:date>
    </item>
    <item>
      <title>Re: Input/Output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/497876#M132130</link>
      <description>&lt;P&gt;Thank you soooo much for your help. I have learnt a lot!!&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 15:42:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-Output/m-p/497876#M132130</guid>
      <dc:creator>talzy7</dc:creator>
      <dc:date>2018-09-21T15:42:37Z</dc:date>
    </item>
  </channel>
</rss>

