<?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 to do that in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Assign-a-value-based-on-date-working-day/m-p/849955#M41891</link>
    <description>&lt;P&gt;What are the rules for "map the date2 at the good value"? I do not see anything that I can follow as to what value is used where.&lt;/P&gt;
&lt;P&gt;You should provide an example of the data after the mapping is done.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What do you mean by "does not like it" in "Please note that I would like to have date2 using yymmddn8. format but I have tried it the code and it does not like it."&lt;/P&gt;
&lt;P&gt;This runs just fine and displays the values of date2 that way:&lt;/P&gt;
&lt;PRE&gt;data want;
infile datalines delimiter=','; 
input date1: yymmdd10. workingday: 1. date2: yymmdd10.;
format date1 yymmdd10. workingday 1. date2 yymmddn8.;
datalines;
2020-01-01,0,20200103
2020-01-02,0,20200103
2020-01-03,1,20200103
2020-01-04,0,20200106
2020-01-05,0,20200106
2020-01-06,1,20200106
2020-01-07,1,20200107
2020-01-08,1,20200108
2020-01-09,1,20200109
2020-01-10,1,20200110
2020-01-11,0,20200113
2020-01-12,0,20200113
2020-01-13,1,20200113
;&lt;/PRE&gt;
&lt;P&gt;There is no INFORMAT of yymmddn8. though.&lt;/P&gt;</description>
    <pubDate>Thu, 15 Dec 2022 21:01:18 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2022-12-15T21:01:18Z</dc:date>
    <item>
      <title>Assign a value based on date / working day</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Assign-a-value-based-on-date-working-day/m-p/849951#M41889</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's my dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to develop some go that will permit to map the date2 at the good value as it is into the dataset, based on date1 and workingday value.&amp;nbsp; When it is a working day, workingday eq one and if not it equals zero.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I would like a sas code example to map date2 base on date1 and workday value.&lt;/P&gt;
&lt;P&gt;Does someone know how to do that ?&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
infile datalines delimiter=','; 
input date1: yymmdd10. workingday: 1. date2: yymmdd10.;
format date1 yymmdd10. workingday 1. date2 yymmdd10.;
datalines;
2020-01-01,0,20200103
2020-01-02,0,20200103
2020-01-03,1,20200103
2020-01-04,0,20200106
2020-01-05,0,20200106
2020-01-06,1,20200106
2020-01-07,1,20200107
2020-01-08,1,20200108
2020-01-09,1,20200109
2020-01-10,1,20200110
2020-01-11,0,20200113
2020-01-12,0,20200113
2020-01-13,1,20200113
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Please note that I would like to have date2 using yymmddn8. format but I have tried it the code and it does not like it.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Dec 2022 21:34:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Assign-a-value-based-on-date-working-day/m-p/849951#M41889</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2022-12-15T21:34:34Z</dc:date>
    </item>
    <item>
      <title>Re: how to do that</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Assign-a-value-based-on-date-working-day/m-p/849954#M41890</link>
      <description>&lt;P&gt;How about&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile datalines delimiter=','; 
input date1: yymmdd10. workingday: 1.;
format date1 yymmdd10. workingday 1.;
datalines;
2020-01-01,0 
2020-01-02,0 
2020-01-03,1 
2020-01-04,0 
2020-01-05,0 
2020-01-06,1 
2020-01-07,1 
2020-01-08,1 
2020-01-09,1 
2020-01-10,1 
2020-01-11,0 
2020-01-12,0 
2020-01-13,1 
;
run;

data want(drop = d);
   do until (workingday);
      set have;
   end;

   d = date1;

   do until (workingday);
      set have;
      date2 = d;
      output;
   end;

   format date2 yymmddn8.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Dec 2022 20:57:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Assign-a-value-based-on-date-working-day/m-p/849954#M41890</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-12-15T20:57:17Z</dc:date>
    </item>
    <item>
      <title>Re: how to do that</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Assign-a-value-based-on-date-working-day/m-p/849955#M41891</link>
      <description>&lt;P&gt;What are the rules for "map the date2 at the good value"? I do not see anything that I can follow as to what value is used where.&lt;/P&gt;
&lt;P&gt;You should provide an example of the data after the mapping is done.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What do you mean by "does not like it" in "Please note that I would like to have date2 using yymmddn8. format but I have tried it the code and it does not like it."&lt;/P&gt;
&lt;P&gt;This runs just fine and displays the values of date2 that way:&lt;/P&gt;
&lt;PRE&gt;data want;
infile datalines delimiter=','; 
input date1: yymmdd10. workingday: 1. date2: yymmdd10.;
format date1 yymmdd10. workingday 1. date2 yymmddn8.;
datalines;
2020-01-01,0,20200103
2020-01-02,0,20200103
2020-01-03,1,20200103
2020-01-04,0,20200106
2020-01-05,0,20200106
2020-01-06,1,20200106
2020-01-07,1,20200107
2020-01-08,1,20200108
2020-01-09,1,20200109
2020-01-10,1,20200110
2020-01-11,0,20200113
2020-01-12,0,20200113
2020-01-13,1,20200113
;&lt;/PRE&gt;
&lt;P&gt;There is no INFORMAT of yymmddn8. though.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Dec 2022 21:01:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Assign-a-value-based-on-date-working-day/m-p/849955#M41891</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-12-15T21:01:18Z</dc:date>
    </item>
    <item>
      <title>Re: how to do that</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Assign-a-value-based-on-date-working-day/m-p/849958#M41892</link>
      <description>&lt;P&gt;So assuming that what you are asking is how to set DATE2 to the NEXT value of DATE1 that is a WORKINGDAY,&amp;nbsp; then the easiest way is to re-order the data in DESCREASING order of DATE1 and just RETAIN the value.&amp;nbsp; (Note that for RETAIN to work correctly the variable cannot be on the input dataset, otherwise each time the SET statement executes the retained value is overwritten by the value read in.)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input date1 :yymmdd10. workingday ;
  format date1 yymmdd10.;
datalines;
2020-01-01 0
2020-01-02 0
2020-01-03 1
2020-01-04 0
2020-01-05 0
2020-01-06 1
2020-01-07 1
2020-01-08 1
2020-01-09 1
2020-01-10 1
2020-01-11 0
2020-01-12 0
2020-01-13 1
;

proc sort data=have;
  by descending date1;
run;

data want;
  set have;
  by descending date1 ;
  retain date2;
  format date2 yymmdd10.;
  if workingday then date2=date1;
run;

proc print;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1671138206598.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/78600i255496836217AE03/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_0-1671138206598.png" alt="Tom_0-1671138206598.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Dec 2022 21:03:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Assign-a-value-based-on-date-working-day/m-p/849958#M41892</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-12-15T21:03:34Z</dc:date>
    </item>
    <item>
      <title>Re: how to do that</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Assign-a-value-based-on-date-working-day/m-p/849967#M41894</link>
      <description>It seems so simple for you and for me I had no idea how to do that.  Sorting by descending order and using a retain statement.  It does exactly what I wish.&lt;BR /&gt;&lt;BR /&gt;Thank you very much&lt;BR /&gt;</description>
      <pubDate>Thu, 15 Dec 2022 21:37:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Assign-a-value-based-on-date-working-day/m-p/849967#M41894</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2022-12-15T21:37:15Z</dc:date>
    </item>
  </channel>
</rss>

