<?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 know if a date from a pipe command is ddmmyyyy or mmddyyyy in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-know-if-a-date-from-a-pipe-command-is-ddmmyyyy-or/m-p/965595#M375900</link>
    <description>&lt;P&gt;Sounds like a question for a Windows forum.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could skip the PIPE and just use SAS code to get the filenames.&lt;/P&gt;
&lt;P&gt;You might try this macro&amp;nbsp;&lt;A href="https://github.com/sasutils/macros/blob/master/dirtree.sas" target="_blank"&gt;https://github.com/sasutils/macros/blob/master/dirtree.sas&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;It might not have your problem since it uses the NLDATM informat to read the lastmod timestamp.&lt;/P&gt;</description>
    <pubDate>Fri, 02 May 2025 13:47:45 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2025-05-02T13:47:45Z</dc:date>
    <item>
      <title>How to know if a date from a pipe command is ddmmyyyy or mmddyyyy</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-know-if-a-date-from-a-pipe-command-is-ddmmyyyy-or/m-p/965548#M375885</link>
      <description>&lt;P&gt;I have written a lot of macros over the past that utilize pipe commands as in the code box below.&amp;nbsp; The date from the dir commands has always been in MM/DD/YYYY for me.&amp;nbsp; This has worked fine for quite some time because everyone that uses my code is either in the US or India, and we have all had our computers set to this format.&amp;nbsp; However, we have been bringing in users from the UK, and they all set their systems to be DD/MM/YYYY.&amp;nbsp; When they run my code, this pipe command swaps the day and month, and then I get invalid notes in my log because they don't consider 29/04/2025 to be a valid date.&amp;nbsp; Visually, I can tell that this is April 29, but since my code is set up to read it as MM/DD/YYYY, it doesn't know what the 29th month is.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With all that background, is there a way to easily tell which format the value is in?&amp;nbsp; I can set up some IF statements such that if the first 2 digits are greater than 12, then I know it's in DD/MM/YYYY format, or if the second 2 digits are greater than 12, then I know it's in MM/DD/YYYY format.&amp;nbsp; However, if both are less than or equal to 12, I won't know.&amp;nbsp; 04/03/2025 could be March 4 or April 3.&amp;nbsp; Has anyone dealt with this scenario before?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename SASlist pipe "dir /t:w &amp;amp;datapath.\*.sas7bdat";

data datadir;
	infile SASlist dlm="¬";
	length buff $2000;
	input buff;
	if _n_&amp;gt;3 &amp;amp; index(buff,"File")=0 &amp;amp; index(buff,"Dir")=0 then do;
		date=input(scan(buff,1,''),mmddyy10.);
		file=scan(buff,-1,'');
		dset=upcase(scan(file,1,'.'));
	end;
	format date date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 May 2025 19:12:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-know-if-a-date-from-a-pipe-command-is-ddmmyyyy-or/m-p/965548#M375885</guid>
      <dc:creator>djbateman</dc:creator>
      <dc:date>2025-05-01T19:12:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to know if a date from a pipe command is ddmmyyyy or mmddyyyy</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-know-if-a-date-from-a-pipe-command-is-ddmmyyyy-or/m-p/965560#M375891</link>
      <description>&lt;P&gt;What do you get when you check the LOCALE system option in the environments?&lt;/P&gt;</description>
      <pubDate>Thu, 01 May 2025 21:20:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-know-if-a-date-from-a-pipe-command-is-ddmmyyyy-or/m-p/965560#M375891</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2025-05-01T21:20:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to know if a date from a pipe command is ddmmyyyy or mmddyyyy</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-know-if-a-date-from-a-pipe-command-is-ddmmyyyy-or/m-p/965568#M375894</link>
      <description>&lt;P&gt;Yeah, as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;suggests, I think you might want to make this a two step process where you first pipe this command to the shell:&lt;/P&gt;
&lt;PRE&gt;Get-WinSystemLocale&lt;/PRE&gt;
&lt;P&gt;...read in the output, and make your determination based on that.&amp;nbsp; You can try this in Powershell just to see the output.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 01 May 2025 23:56:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-know-if-a-date-from-a-pipe-command-is-ddmmyyyy-or/m-p/965568#M375894</guid>
      <dc:creator>quickbluefish</dc:creator>
      <dc:date>2025-05-01T23:56:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to know if a date from a pipe command is ddmmyyyy or mmddyyyy</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-know-if-a-date-from-a-pipe-command-is-ddmmyyyy-or/m-p/965579#M375897</link>
      <description>&lt;P&gt;You could try option datastyle= and using informat anydtdte32. in input()&amp;nbsp; function.&lt;/P&gt;
&lt;PRE&gt;option datestyle=dmy;
.........
date=input(scan(buff,1,''),anydtdte32.);

&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 May 2025 06:07:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-know-if-a-date-from-a-pipe-command-is-ddmmyyyy-or/m-p/965579#M375897</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-05-02T06:07:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to know if a date from a pipe command is ddmmyyyy or mmddyyyy</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-know-if-a-date-from-a-pipe-command-is-ddmmyyyy-or/m-p/965595#M375900</link>
      <description>&lt;P&gt;Sounds like a question for a Windows forum.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could skip the PIPE and just use SAS code to get the filenames.&lt;/P&gt;
&lt;P&gt;You might try this macro&amp;nbsp;&lt;A href="https://github.com/sasutils/macros/blob/master/dirtree.sas" target="_blank"&gt;https://github.com/sasutils/macros/blob/master/dirtree.sas&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;It might not have your problem since it uses the NLDATM informat to read the lastmod timestamp.&lt;/P&gt;</description>
      <pubDate>Fri, 02 May 2025 13:47:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-know-if-a-date-from-a-pipe-command-is-ddmmyyyy-or/m-p/965595#M375900</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-05-02T13:47:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to know if a date from a pipe command is ddmmyyyy or mmddyyyy</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-know-if-a-date-from-a-pipe-command-is-ddmmyyyy-or/m-p/965597#M375901</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;, I didn't have much luck with that method.&amp;nbsp; You can see below that it properly got March 31, but I changed Feb 6 and May 2 to June 2 and Feb 5, respectively.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Picture1.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/106665i55D26BF6E960C7F7/image-size/large?v=v2&amp;amp;px=999" role="button" title="Picture1.png" alt="Picture1.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 May 2025 13:56:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-know-if-a-date-from-a-pipe-command-is-ddmmyyyy-or/m-p/965597#M375901</guid>
      <dc:creator>djbateman</dc:creator>
      <dc:date>2025-05-02T13:56:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to know if a date from a pipe command is ddmmyyyy or mmddyyyy</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-know-if-a-date-from-a-pipe-command-is-ddmmyyyy-or/m-p/965602#M375904</link>
      <description>&lt;P&gt;The DATESTYLE= option will control how the ANYDT... informats handle the ambiguous date strings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try it yourself.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input name $ string :$10. ;
cards;
MDY 1/31/2025
DMY 31/1/2025
??? 2/6/2025
;

%let datestyle=%sysfunc(getoption(datestyle));
%put &amp;amp;=datestyle;

options datestyle=MDY;
data mdy;
  set have;
  mdy = input(string,anydtdte10.);
  format mdy date9.;
run;

options datestyle=DMY;
data dmy;
  set have;
  dmy = input(string,anydtdte10.);
  format dmy date9.;
run;

options datastyle=&amp;amp;datestyle;

data both;
  merge mdy dmy ;
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-1746195705926.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/106666iE7AC436BB0172638/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_0-1746195705926.png" alt="Tom_0-1746195705926.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The trick is know which setting to use.&amp;nbsp; That is a Windows question, not a SAS question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Although if your SAS session is using a similar locale as your Windows system (or is it the Windows file system that controls how DIR formats its output?) then using DATESTYLE=LOCALE might help.&lt;/P&gt;</description>
      <pubDate>Fri, 02 May 2025 14:24:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-know-if-a-date-from-a-pipe-command-is-ddmmyyyy-or/m-p/965602#M375904</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-05-02T14:24:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to know if a date from a pipe command is ddmmyyyy or mmddyyyy</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-know-if-a-date-from-a-pipe-command-is-ddmmyyyy-or/m-p/965603#M375905</link>
      <description>&lt;P&gt;Maybe this would work for you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;reg query "HKCU\Control Panel\International" /v sShortDate

HKEY_CURRENT_USER\Control Panel\International
    sShortDate    REG_SZ    M/d/yyyy&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use INFILE statement option FILEVAR to execute multiple PIPEed commands.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 May 2025 14:41:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-know-if-a-date-from-a-pipe-command-is-ddmmyyyy-or/m-p/965603#M375905</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2025-05-02T14:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to know if a date from a pipe command is ddmmyyyy or mmddyyyy</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-know-if-a-date-from-a-pipe-command-is-ddmmyyyy-or/m-p/965619#M375908</link>
      <description>&lt;P&gt;I think I can work with this.&amp;nbsp; Thank you for the direction!&lt;/P&gt;</description>
      <pubDate>Fri, 02 May 2025 15:46:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-know-if-a-date-from-a-pipe-command-is-ddmmyyyy-or/m-p/965619#M375908</guid>
      <dc:creator>djbateman</dc:creator>
      <dc:date>2025-05-02T15:46:58Z</dc:date>
    </item>
  </channel>
</rss>

