<?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: Modify Reading Date formats from a RDBMS/Cloud DWH table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Modify-Reading-Date-formats-from-a-RDBMS-Cloud-DWH-table/m-p/685561#M207937</link>
    <description>&lt;P&gt;I think you over-complicate. This is more compact:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro apply_date_format(inlib=, viewlib=, dateformat=);

proc contents data=&amp;amp;inlib.._ALL_ out=CONTENTS noprint;
run;

data _null_;
  set CONTENTS;
  where fmtinfo(FORMAT,'cat')='date';
  by MEMNAME notsorted;
  if first.MEMNAME then 
    call execute("data &amp;amp;viewlib.."||MEMNAME||"/view=&amp;amp;viewlib.."||MEMNAME||";set &amp;amp;inlib.."||MEMNAME||";");
  call execute("format "||NAME||" &amp;amp;dateformat;"); 
run;
run;

%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 22 Sep 2020 02:54:18 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2020-09-22T02:54:18Z</dc:date>
    <item>
      <title>Modify Reading Date formats from a RDBMS/Cloud DWH table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modify-Reading-Date-formats-from-a-RDBMS-Cloud-DWH-table/m-p/684790#M207586</link>
      <description>&lt;P&gt;Hello SAS Experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a Redshift table(x) that has around 100 date columns out of 300 columns and we have&amp;nbsp; SAS/Access Redshift library in our environment to access Redshift tables&amp;nbsp; I am querying this Redshift table(x) in SAS Studio using SAS/Access Libname engine to generate a report. In this report, all 100 columns date values are appearing as Date9. formatted values, If I open Redshift table in SAS, Data is appearing as Date9. formatted values. SAS is auto assigning to Date9. format. I know it is the default behaviour.&amp;nbsp; Is there any way to change this behaviour of reading date values format from "Date9." to other Date formats for Ex: MMDDYY10. format or YYMMDD10. format.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not creating any temporary dataset using the Redshift table to generate Reports to apply explicit date conversions using format statement or sasdatefmt= dataset option. Also, I don't want to write the format statement for all 100 date variables in reporting steps. Since it will hard for me to write for all variables. There is no pattern as well to identify Date variables with suffixes or prefixes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It would be helpful if there is any way to change this behaviour using the global option/library option or any other method that changes this behaviour?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&amp;nbsp;&lt;/P&gt;&lt;P&gt;Bhanu&lt;/P&gt;</description>
      <pubDate>Thu, 17 Sep 2020 20:24:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modify-Reading-Date-formats-from-a-RDBMS-Cloud-DWH-table/m-p/684790#M207586</guid>
      <dc:creator>bhanucharan</dc:creator>
      <dc:date>2020-09-17T20:24:07Z</dc:date>
    </item>
    <item>
      <title>Re: Modify Reading Date formats from a RDBMS/Cloud DWH table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modify-Reading-Date-formats-from-a-RDBMS-Cloud-DWH-table/m-p/684832#M207612</link>
      <description>&lt;P&gt;I don't know of such an option, but it would be a great idea. Add it the the &lt;A href="https://communities.sas.com/t5/SASware-Ballot-Ideas/idb-p/sas_ideas" target="_self"&gt;sasware&lt;/A&gt; ballot?&lt;/P&gt;
&lt;P&gt;You can easily change the format afterwards. See&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Procedures/Change-DATE-formats-to-DDMMYYS10-for-ALL-unknown-number-date/td-p/366637" target="_self"&gt;&lt;SPAN&gt;Change DATE formats to DDMMYYS10. for ALL (unknown number) date variables in a data set/LIBRARY&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Sep 2020 00:13:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modify-Reading-Date-formats-from-a-RDBMS-Cloud-DWH-table/m-p/684832#M207612</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-09-18T00:13:28Z</dc:date>
    </item>
    <item>
      <title>Re: Modify Reading Date formats from a RDBMS/Cloud DWH table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modify-Reading-Date-formats-from-a-RDBMS-Cloud-DWH-table/m-p/684863#M207624</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your response!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sure i will post the idea in sasware ballot.&lt;/P&gt;&lt;P&gt;The reference link that you had shared will help if it is a SAS dataset&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Procedures/Change-DATE-formats-to-DDMMYYS10-for-ALL-unknown-number-date/td-p/366637" target="_self"&gt;&lt;SPAN&gt;Change DATE formats to DDMMYYS10. for ALL (unknown number) date variables in a data set/LIBRARY.&amp;nbsp;&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Proc datasets modify option will not work with RDBMS/Cloud Dwh.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Bhanu&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Sep 2020 03:54:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modify-Reading-Date-formats-from-a-RDBMS-Cloud-DWH-table/m-p/684863#M207624</guid>
      <dc:creator>bhanucharan</dc:creator>
      <dc:date>2020-09-18T03:54:34Z</dc:date>
    </item>
    <item>
      <title>Re: Modify Reading Date formats from a RDBMS/Cloud DWH table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modify-Reading-Date-formats-from-a-RDBMS-Cloud-DWH-table/m-p/684866#M207626</link>
      <description>You use the code on the link after you have read the data into SAS.&lt;BR /&gt;</description>
      <pubDate>Fri, 18 Sep 2020 04:04:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modify-Reading-Date-formats-from-a-RDBMS-Cloud-DWH-table/m-p/684866#M207626</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-09-18T04:04:08Z</dc:date>
    </item>
    <item>
      <title>Re: Modify Reading Date formats from a RDBMS/Cloud DWH table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modify-Reading-Date-formats-from-a-RDBMS-Cloud-DWH-table/m-p/684869#M207627</link>
      <description>&lt;P&gt;My requirement is to generate a report from the Redshift table ie., Read from the DB table and generate a report. The shared code will not help in my scenario.&lt;/P&gt;&lt;P&gt;The below code (from the shared link) modifies the SAS Dataset formats. This below code will work in the scenario "if i am writing to SAS dataset from Redshift table and generate a report using SAS dataset", this code will modify all date variables stored in a SAS dataset.&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class="language-sas"&gt;&lt;CODE&gt;data _null_;
  set contents;
  where fmtinfo(format,'cat')='date';
  by libname memname ;
  if first.libname then call execute(catx(' ','proc datasets nolist lib=',libname,';')) ;
  if first.memname then call execute(catx(' ','modify',memname,';format',name)) ;
  else call execute(' '||trim(name)) ;
  if last.memname then call execute(' DDMMYYS10.; run;') ;
  if last.libname then call execute('quit;') ;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Sep 2020 04:16:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modify-Reading-Date-formats-from-a-RDBMS-Cloud-DWH-table/m-p/684869#M207627</guid>
      <dc:creator>bhanucharan</dc:creator>
      <dc:date>2020-09-18T04:16:58Z</dc:date>
    </item>
    <item>
      <title>Re: Modify Reading Date formats from a RDBMS/Cloud DWH table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modify-Reading-Date-formats-from-a-RDBMS-Cloud-DWH-table/m-p/684871#M207629</link>
      <description>&lt;P&gt;If there is no global option to change the default format, you have 2 options:&lt;/P&gt;
&lt;P&gt;1. Surely the report only includes a few variables, not 100 or 300. Change the formats in the report.&lt;/P&gt;
&lt;P&gt;2. Modify the linked code slightly so it creates view that contains the wanted formats. You can use that view to create reports.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Sep 2020 04:56:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modify-Reading-Date-formats-from-a-RDBMS-Cloud-DWH-table/m-p/684871#M207629</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-09-18T04:56:47Z</dc:date>
    </item>
    <item>
      <title>Re: Modify Reading Date formats from a RDBMS/Cloud DWH table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modify-Reading-Date-formats-from-a-RDBMS-Cloud-DWH-table/m-p/684973#M207678</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;The second option might work, Thanks for your help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Sep 2020 13:59:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modify-Reading-Date-formats-from-a-RDBMS-Cloud-DWH-table/m-p/684973#M207678</guid>
      <dc:creator>bhanucharan</dc:creator>
      <dc:date>2020-09-18T13:59:09Z</dc:date>
    </item>
    <item>
      <title>Re: Modify Reading Date formats from a RDBMS/Cloud DWH table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modify-Reading-Date-formats-from-a-RDBMS-Cloud-DWH-table/m-p/685487#M207900</link>
      <description>&lt;P&gt;View option worked! Below is the code that i have developed:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro apply_date_format(saslibref=,redshiftlibref=,sasformat=);&lt;/P&gt;&lt;P&gt;proc contents data=&amp;amp;redshiftlibref.._all_ noprint out=contents;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data datecol;&lt;BR /&gt;set contents;&lt;BR /&gt;where fmtinfo(format,'cat')='date';&lt;BR /&gt;by libname memname ;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sort data=datecol out= ds_name nodupkey;&lt;BR /&gt;by libname memname;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%let opentable = %sysfunc(OPEN(ds_name , IS));&lt;BR /&gt;%if &amp;amp;openTable %then %do;&lt;BR /&gt;%let nobs = %sysfunc(attrn(&amp;amp;openTable, nobs));&lt;BR /&gt;%let closeTable=%sysfunc(CLOSE(&amp;amp;openTable));&lt;BR /&gt;%end;&lt;BR /&gt;%else %do;&lt;BR /&gt;%put No date variables in the library. Ending the sas program;&lt;BR /&gt;%goto program_end;&lt;BR /&gt;%end;&lt;BR /&gt;%put &amp;amp;nobs;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;BR /&gt;select distinct lowcase(libname), lowcase(memname)&lt;BR /&gt;into: libname1 - :libname&amp;amp;nobs, :memname1 - :memname&amp;amp;nobs&lt;BR /&gt;from ds_name;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%do i=1 %to &amp;amp;nobs;&lt;BR /&gt;proc sql noprint;&lt;BR /&gt;select distinct name into:datecolnames separated by " "&lt;BR /&gt;from datecol&lt;BR /&gt;where lowcase(libname) = "&amp;amp;&amp;amp;libname&amp;amp;i"&lt;BR /&gt;and lowcase(memname) = "&amp;amp;&amp;amp;memname&amp;amp;i"&lt;BR /&gt;;&lt;BR /&gt;quit;&lt;BR /&gt;%put datasetname= &amp;amp;&amp;amp;libname&amp;amp;i...&amp;amp;&amp;amp;memname&amp;amp;i datevariables = &amp;amp;datecolnames;&lt;/P&gt;&lt;P&gt;data &amp;amp;saslibref..&amp;amp;&amp;amp;memname&amp;amp;i / view= &amp;amp;saslibref..&amp;amp;&amp;amp;memname&amp;amp;i;&lt;BR /&gt;set &amp;amp;&amp;amp;libname&amp;amp;i...&amp;amp;&amp;amp;memname&amp;amp;i;&lt;BR /&gt;;&lt;BR /&gt;format &amp;amp;datecolnames &amp;amp;sasformat;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%end;&lt;BR /&gt;%program_end:&lt;BR /&gt;%put End of the program;&lt;BR /&gt;%mend;&lt;BR /&gt;%apply_date_format(saslibref=saslib,redshiftlibref=rslib,sasformat=mmddyy10.);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;saslib =&amp;gt; Target sas library where you want to store your sas view.&lt;/P&gt;&lt;P&gt;rslib =&amp;gt; Redshift source library&lt;/P&gt;&lt;P&gt;mmddyy10. =&amp;gt; Format to be applied&lt;/P&gt;</description>
      <pubDate>Mon, 21 Sep 2020 17:21:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modify-Reading-Date-formats-from-a-RDBMS-Cloud-DWH-table/m-p/685487#M207900</guid>
      <dc:creator>bhanucharan</dc:creator>
      <dc:date>2020-09-21T17:21:19Z</dc:date>
    </item>
    <item>
      <title>Re: Modify Reading Date formats from a RDBMS/Cloud DWH table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modify-Reading-Date-formats-from-a-RDBMS-Cloud-DWH-table/m-p/685561#M207937</link>
      <description>&lt;P&gt;I think you over-complicate. This is more compact:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro apply_date_format(inlib=, viewlib=, dateformat=);

proc contents data=&amp;amp;inlib.._ALL_ out=CONTENTS noprint;
run;

data _null_;
  set CONTENTS;
  where fmtinfo(FORMAT,'cat')='date';
  by MEMNAME notsorted;
  if first.MEMNAME then 
    call execute("data &amp;amp;viewlib.."||MEMNAME||"/view=&amp;amp;viewlib.."||MEMNAME||";set &amp;amp;inlib.."||MEMNAME||";");
  call execute("format "||NAME||" &amp;amp;dateformat;"); 
run;
run;

%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Sep 2020 02:54:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modify-Reading-Date-formats-from-a-RDBMS-Cloud-DWH-table/m-p/685561#M207937</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-09-22T02:54:18Z</dc:date>
    </item>
    <item>
      <title>Re: Modify Reading Date formats from a RDBMS/Cloud DWH table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modify-Reading-Date-formats-from-a-RDBMS-Cloud-DWH-table/m-p/685571#M207942</link>
      <description>&lt;P&gt;Thanks, You are right. Missed the Call execute Option.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Sep 2020 03:30:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modify-Reading-Date-formats-from-a-RDBMS-Cloud-DWH-table/m-p/685571#M207942</guid>
      <dc:creator>bhanucharan</dc:creator>
      <dc:date>2020-09-22T03:30:53Z</dc:date>
    </item>
  </channel>
</rss>

