<?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 eliminate &amp;quot;UN&amp;quot; ( Month / date) from given date data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-eliminate-quot-UN-quot-Month-date-from-given-date-data/m-p/681776#M206270</link>
    <description>&lt;P&gt;I get the idea of translating UN to hyphens.&lt;/P&gt;
&lt;P&gt;My question why would you keep the day of the month when the actual month is not present.&amp;nbsp; How can you have any confidence in the day of the month provided if the month itself is not known?&amp;nbsp; Perhaps it is even more likely that they meant the month number and not the day number.&lt;/P&gt;</description>
    <pubDate>Sat, 05 Sep 2020 03:03:47 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2020-09-05T03:03:47Z</dc:date>
    <item>
      <title>How to eliminate "UN" ( Month / date) from given date data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-eliminate-quot-UN-quot-Month-date-from-given-date-data/m-p/680237#M205538</link>
      <description>&lt;P&gt;Hi Reader,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My requirement is&amp;nbsp;&amp;amp;output_date . I have created below program but no satisfied and still I want to cut short this macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kindly suggest me more dynamic way for below mention senerio to get&amp;nbsp;&amp;amp;output_date. Or there any other approch which I can do it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data un_date ;&lt;BR /&gt;input date1$ 10.;&lt;BR /&gt;CARDS;&lt;BR /&gt;2001-UN-UN&lt;BR /&gt;2002-12-UN&lt;BR /&gt;2006-11-UN&lt;BR /&gt;2004-UN-02&lt;BR /&gt;2001&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;****My pr0gram*****&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro offset_date(date1, output_date, indset , outdset);&lt;BR /&gt;data &amp;amp;outdset ;&lt;BR /&gt;set &amp;amp;indset ;&lt;BR /&gt;if &amp;amp;date1 ne "" then do ;&lt;BR /&gt;if index(&amp;amp;date1,"UN")=0 then &amp;amp;output_date=&amp;amp;date1;&lt;BR /&gt;else if index(&amp;amp;date1,"UN")&amp;gt; 0 then do;&lt;BR /&gt;if scan(&amp;amp;date1,2,"-") eq "UN" and scan(&amp;amp;date1,3,"-") ne "UN" then &amp;amp;output_date=tranwrd(&amp;amp;date1,"-UN-","----");&lt;BR /&gt;if scan(&amp;amp;date1,2,"-") ne "UN" and scan(&amp;amp;date1,3,"-") eq "UN" then &amp;amp;output_date=tranwrd(&amp;amp;date1,"-UN","");&lt;BR /&gt;if scan(&amp;amp;date1,2,"-") eq "UN" and scan(&amp;amp;date1,3,"-") eq "UN" then &amp;amp;output_date=tranwrd(&amp;amp;date1,"-UN-UN","");&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt;%mend offset_date;&lt;BR /&gt;%offset_date(date1, output_date, un_date, un_data);&lt;/P&gt;</description>
      <pubDate>Sat, 29 Aug 2020 18:24:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-eliminate-quot-UN-quot-Month-date-from-given-date-data/m-p/680237#M205538</guid>
      <dc:creator>pdhokriya</dc:creator>
      <dc:date>2020-08-29T18:24:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to eliminate "UN" ( Month / date) from given date data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-eliminate-quot-UN-quot-Month-date-from-given-date-data/m-p/680241#M205541</link>
      <description>&lt;P&gt;You're telling us that your code is not satisfactory, yet you don't tell us what you want the results to look like.&amp;nbsp; Please provide the desired values for each of your starting values.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is just a guess on my part.&amp;nbsp; But you would probably get more, and better, responses is you showed explicit desired results.&amp;nbsp; Help us help you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data un_date ;
input &amp;amp;date1$ 10.;
CARDS;
2001-UN-UN
2002-12-UN
2006-11-UN
2004-UN-02
2001
;
run;
%let date1=date1;
%let output_date=date2;
data want;
  set un_date;
  &amp;amp;output_date=&amp;amp;date1 ;
  if index(&amp;amp;date1,'UN')&amp;gt;0 then do;
    &amp;amp;output_date=tranwrd(&amp;amp;output_date,'-UN-UN','');    
    &amp;amp;output_date=tranwrd(&amp;amp;output_date,'-UN-','----'); 
    &amp;amp;output_date=tranwrd(&amp;amp;output_date,'-UN','');      
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can put this code into a macro, instead my open code solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you should bother with scanning for specific pattern combinations.&amp;nbsp; Instead transform in this specific sequence: the double UN first, then the trailing UN, and the internal UN.&amp;nbsp; There will be no need for if tests since whichever of these conditions is discovered first, subsequent conditions will not arise.&lt;/P&gt;</description>
      <pubDate>Sat, 29 Aug 2020 19:34:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-eliminate-quot-UN-quot-Month-date-from-given-date-data/m-p/680241#M205541</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-08-29T19:34:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to eliminate "UN" ( Month / date) from given date data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-eliminate-quot-UN-quot-Month-date-from-given-date-data/m-p/680274#M205551</link>
      <description>Thank you so much for the suggested solution.&lt;BR /&gt;&lt;BR /&gt;Can you share the syntax in Proc sql too.</description>
      <pubDate>Sun, 30 Aug 2020 08:34:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-eliminate-quot-UN-quot-Month-date-from-given-date-data/m-p/680274#M205551</guid>
      <dc:creator>pdhokriya</dc:creator>
      <dc:date>2020-08-30T08:34:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to eliminate "UN" ( Month / date) from given date data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-eliminate-quot-UN-quot-Month-date-from-given-date-data/m-p/680312#M205562</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/55374"&gt;@pdhokriya&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thank you so much for the suggested solution.&lt;BR /&gt;&lt;BR /&gt;Can you share the syntax in Proc sql too.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I leave that to you.&amp;nbsp; But here's a data step program that you should be able to replicate in SQL using the CASE expression:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set un_date;
  if index(&amp;amp;date1,'-UN-UN') then &amp;amp;output_date=tranwrd(&amp;amp;date1,'-UN-UN','');    else
  if index(&amp;amp;date1,'-UN-')   then &amp;amp;output_date=tranwrd(&amp;amp;date1,'-UN-','----');  else
  &amp;amp;output_date=tranwrd(&amp;amp;date1,'-UN','');      
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 30 Aug 2020 13:47:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-eliminate-quot-UN-quot-Month-date-from-given-date-data/m-p/680312#M205562</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-08-30T13:47:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to eliminate "UN" ( Month / date) from given date data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-eliminate-quot-UN-quot-Month-date-from-given-date-data/m-p/680390#M205615</link>
      <description>&lt;P&gt;Another way&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WANT ;
  input DATE1 $10.; 
  DATE2 = prxchange( 's/-UN//', 2, prxchange( 's/(\d-)UN(-\d)/\1--\2/', 1, DATE1 ) );
cards;
2001-UN-UN
2002-12-UN
2006-11-UN
2004-UN-02
2001
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;&lt;A name="IDX" target="_blank"&gt;&lt;/A&gt;
&lt;DIV&gt;
&lt;DIV align="left"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.WANT" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt;&lt;/COLGROUP&gt; &lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r header" scope="col"&gt;Obs&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;DATE1&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;DATE2&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;1&lt;/TH&gt;
&lt;TD class="l data"&gt;2001-UN-UN&lt;/TD&gt;
&lt;TD class="l data"&gt;2001&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;2&lt;/TH&gt;
&lt;TD class="l data"&gt;2002-12-UN&lt;/TD&gt;
&lt;TD class="l data"&gt;2002-12&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;3&lt;/TH&gt;
&lt;TD class="l data"&gt;2006-11-UN&lt;/TD&gt;
&lt;TD class="l data"&gt;2006-11&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;4&lt;/TH&gt;
&lt;TD class="l data"&gt;2004-UN-02&lt;/TD&gt;
&lt;TD class="l data"&gt;2004----02&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;5&lt;/TH&gt;
&lt;TD class="l data"&gt;2001&lt;/TD&gt;
&lt;TD class="l data"&gt;2001&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Aug 2020 08:33:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-eliminate-quot-UN-quot-Month-date-from-given-date-data/m-p/680390#M205615</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-08-31T08:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to eliminate "UN" ( Month / date) from given date data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-eliminate-quot-UN-quot-Month-date-from-given-date-data/m-p/681053#M205954</link>
      <description>So more than 1 date how can I handle ?&lt;BR /&gt;data WANT ;&lt;BR /&gt;  input cmstdat $10. cmendat $11.; &lt;BR /&gt;cards;&lt;BR /&gt;2001-UN-UN 2001-UN-01&lt;BR /&gt;2002-12-UN 2001&lt;BR /&gt;2006-11-UN 2001-01-UN&lt;BR /&gt;2004-UN-02 2001-UN-02&lt;BR /&gt;2008-03-03&lt;BR /&gt;2001&lt;BR /&gt;&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;%let input_date=cmstdat;&lt;BR /&gt;%let output_date=cmstdtc;&lt;BR /&gt;&lt;BR /&gt;data example3;&lt;BR /&gt;  set want;&lt;BR /&gt;  &amp;amp;output_date=&amp;amp;input_date ;&lt;BR /&gt;  if index(&amp;amp;input_date,'UN')&amp;gt;0 then do;&lt;BR /&gt;    &amp;amp;output_date=tranwrd(&amp;amp;output_date,'-UN-UN','');    &lt;BR /&gt;    &amp;amp;output_date=tranwrd(&amp;amp;output_date,'-UN-','----'); &lt;BR /&gt;    &amp;amp;output_date=tranwrd(&amp;amp;output_date,'-UN','');      &lt;BR /&gt;  end;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;So Can I use %macro; %mend?</description>
      <pubDate>Wed, 02 Sep 2020 16:34:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-eliminate-quot-UN-quot-Month-date-from-given-date-data/m-p/681053#M205954</guid>
      <dc:creator>pdhokriya</dc:creator>
      <dc:date>2020-09-02T16:34:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to eliminate "UN" ( Month / date) from given date data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-eliminate-quot-UN-quot-Month-date-from-given-date-data/m-p/681058#M205957</link>
      <description>&lt;P&gt;I am curious.&amp;nbsp; What is the meaning of a value like&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;2004-UN-02?&amp;nbsp; Is that supposed to indicate that it was the second day of the month but they can't remember which month?&amp;nbsp; How much values does the 02 actually add in that case?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Sep 2020 16:47:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-eliminate-quot-UN-quot-Month-date-from-given-date-data/m-p/681058#M205957</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-09-02T16:47:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to eliminate "UN" ( Month / date) from given date data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-eliminate-quot-UN-quot-Month-date-from-given-date-data/m-p/681550#M206159</link>
      <description>I am not sure about your question but still for your understanding , ----------------------------yyyy-mm-dd format so if month is missing we generally cosider it UN in raw data , targeted data we consider it as "--" so in future it can be 01 to 12 month.&lt;BR /&gt;&lt;BR /&gt;Hope you get it.</description>
      <pubDate>Fri, 04 Sep 2020 05:11:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-eliminate-quot-UN-quot-Month-date-from-given-date-data/m-p/681550#M206159</guid>
      <dc:creator>pdhokriya</dc:creator>
      <dc:date>2020-09-04T05:11:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to eliminate "UN" ( Month / date) from given date data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-eliminate-quot-UN-quot-Month-date-from-given-date-data/m-p/681776#M206270</link>
      <description>&lt;P&gt;I get the idea of translating UN to hyphens.&lt;/P&gt;
&lt;P&gt;My question why would you keep the day of the month when the actual month is not present.&amp;nbsp; How can you have any confidence in the day of the month provided if the month itself is not known?&amp;nbsp; Perhaps it is even more likely that they meant the month number and not the day number.&lt;/P&gt;</description>
      <pubDate>Sat, 05 Sep 2020 03:03:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-eliminate-quot-UN-quot-Month-date-from-given-date-data/m-p/681776#M206270</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-09-05T03:03:47Z</dc:date>
    </item>
  </channel>
</rss>

