<?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: Unknown timeformat in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Unknown-timeformat/m-p/493325#M129770</link>
    <description>&lt;P&gt;Dear Kurt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;documentation.sas.com seems like a very important reference to know. I will keep that for future reference!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jacob&lt;/P&gt;</description>
    <pubDate>Fri, 07 Sep 2018 09:27:44 GMT</pubDate>
    <dc:creator>jbrau123</dc:creator>
    <dc:date>2018-09-07T09:27:44Z</dc:date>
    <item>
      <title>Unknown timeformat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unknown-timeformat/m-p/492912#M129628</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a text variable with the format "YYYY-MM-DD" that I would like to format as date, but as far as I can see SAS does not support this particular format. If it did, I guess it would be called "YYYYMMDD10.".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I guess I could use substr to grab year, month and date seperately, but I was hoping for a smarter solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope someone can help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jacob&lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 08:35:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unknown-timeformat/m-p/492912#M129628</guid>
      <dc:creator>jbrau123</dc:creator>
      <dc:date>2018-09-06T08:35:21Z</dc:date>
    </item>
    <item>
      <title>Re: Unknown timeformat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unknown-timeformat/m-p/492915#M129629</link>
      <description>&lt;P&gt;Sorry, your post makes absolutely no sense.&amp;nbsp; Your subject is unkown timeformat, but then you proceed to talk about a date.&amp;nbsp; You provide the answer to your question and then say it doesn't exist?&lt;/P&gt;
&lt;PRE&gt;data want;
  a="2018-10-10";
  b=input(a,yymmdd10.);
  format b date9.;
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Sep 2018 08:47:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unknown-timeformat/m-p/492915#M129629</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-06T08:47:54Z</dc:date>
    </item>
    <item>
      <title>Re: Unknown timeformat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unknown-timeformat/m-p/492917#M129630</link>
      <description>&lt;P&gt;Dear RW9&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am a rookie so please apologize if my description is inadequate. I'm more used to other software, such as STATA.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got an unknown format error when I tried to use the format logic of SAS although YYYYMM10. was not listed as known format in the SAS documentation I could find. You write "YY" not "YYYY". I assumed those two were different.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your code seems to just make a new dataset with just one observation and two variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jacob&lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 09:00:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unknown-timeformat/m-p/492917#M129630</guid>
      <dc:creator>jbrau123</dc:creator>
      <dc:date>2018-09-06T09:00:09Z</dc:date>
    </item>
    <item>
      <title>Re: Unknown timeformat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unknown-timeformat/m-p/492923#M129632</link>
      <description>&lt;P&gt;No probs.&amp;nbsp; A time format is different to a date format, the format being number of seconds since 00:00 displayed as a time, and the date being a count of days since the cuttoff point, displayed as a date, so different.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes, there is no YYYYMMDD10 format, only YYMMDD10 format, the actual display is based on the length given in the format, so:&lt;BR /&gt;yymmdd8. will just display year as two numbers, where yymmdd10 will display year as four digits, per the documentation:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000197961.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000197961.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The datastep was just to show you a working example of reading in per a format.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 09:20:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unknown-timeformat/m-p/492923#M129632</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-06T09:20:38Z</dc:date>
    </item>
    <item>
      <title>Re: Unknown timeformat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unknown-timeformat/m-p/492929#M129633</link>
      <description>&lt;P&gt;Maxim 1: read the documentation.&lt;/P&gt;
&lt;P&gt;Browse documentation.sas.com&lt;/P&gt;
&lt;P&gt;Select SAS 9.4 and Viya 3.4 Programming Documentation&lt;/P&gt;
&lt;P&gt;There, navigate to&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Data Step Programming&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Formats and Informats&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SAS Informats&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dictionary of Informats&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Informats by Category&lt;/P&gt;
&lt;P&gt;Scroll down to category Date and Time&lt;/P&gt;
&lt;P&gt;Browse through this list until you find what you need, which is the yymmdd informat in your case.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 09:36:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unknown-timeformat/m-p/492929#M129633</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-09-06T09:36:55Z</dc:date>
    </item>
    <item>
      <title>Re: Unknown timeformat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unknown-timeformat/m-p/492985#M129664</link>
      <description>&lt;P&gt;SAS won't format text strings as dates.&amp;nbsp; Dates in SAS have to be converted to a number, and a format applied to the number.&amp;nbsp; That's why the&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt;&amp;nbsp;solution applies the INPUT function.&amp;nbsp; If you want to replace the original text variable name with a numeric value, you need to jump through a hoop or two.&amp;nbsp; Since you didn't tell us the name of your variable, I'll call it DATEVAR:&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;tempvar = input(datevar, yymmdd10.);&lt;/P&gt;
&lt;P&gt;format tempvar&amp;nbsp; &amp;nbsp;/* FORMAT NAME GOES HERE, see below */;&lt;/P&gt;
&lt;P&gt;drop datevar;&lt;/P&gt;
&lt;P&gt;rename tempvar = datevar;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The FORMAT statement can supply any date format that you would like.&amp;nbsp; A few examples:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;mmddyy10.&lt;/P&gt;
&lt;P&gt;yymmdd10.&lt;/P&gt;
&lt;P&gt;yymmddd10.&lt;/P&gt;
&lt;P&gt;yymmdds10.&lt;/P&gt;
&lt;P&gt;date9.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 12:31:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unknown-timeformat/m-p/492985#M129664</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-09-06T12:31:51Z</dc:date>
    </item>
    <item>
      <title>Re: Unknown timeformat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unknown-timeformat/m-p/492987#M129666</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/228622"&gt;@jbrau123&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a text variable with the format "YYYY-MM-DD" that I would like to format as date, but as far as I can see SAS does not support this particular format. If it did, I guess it would be called "YYYYMMDD10.".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I guess I could use substr to grab year, month and date seperately, but I was hoping for a smarter solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope someone can help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jacob&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;YYMMDD is the name of the informat you can use to convert strings that have dates specified in year, month, day order into actual date values. There is also a YYMMDD format (and many other date formats) to control how SAS displays the date value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS also has an informat named ANYDTDTE that is useful for converting strings into dates. It can handle many different ways that your date value might appear in your character variable.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 12:44:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unknown-timeformat/m-p/492987#M129666</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-09-06T12:44:20Z</dc:date>
    </item>
    <item>
      <title>Re: Unknown timeformat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unknown-timeformat/m-p/493325#M129770</link>
      <description>&lt;P&gt;Dear Kurt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;documentation.sas.com seems like a very important reference to know. I will keep that for future reference!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jacob&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2018 09:27:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unknown-timeformat/m-p/493325#M129770</guid>
      <dc:creator>jbrau123</dc:creator>
      <dc:date>2018-09-07T09:27:44Z</dc:date>
    </item>
    <item>
      <title>Re: Unknown timeformat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unknown-timeformat/m-p/493340#M129775</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/228622"&gt;@jbrau123&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Dear Kurt&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;documentation.sas.com seems like a very important reference to know. I will keep that for future reference!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jacob&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It will take some time to get used to the navigational layout (especially for those of us who are used to the previous online doc at support.sas.com), and it's not complete by far yet, but I've seen the development over the past few months, and it's promising.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2018 10:09:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unknown-timeformat/m-p/493340#M129775</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-09-07T10:09:41Z</dc:date>
    </item>
    <item>
      <title>Re: Unknown timeformat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unknown-timeformat/m-p/493450#M129812</link>
      <description>&lt;P&gt;Thank you very much&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Samlet6;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Samlet5;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;tempvar=input(ansattid,&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;yymmdd10.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;format&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; tempvar &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;date9.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;drop&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; datevar;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;rename&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; tempvar=ansattid2; /* I preferred not to&amp;nbsp;overwrite */&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;but for some reason it only gave me the date for some, not all,&amp;nbsp;of the observations (see picture below).&amp;nbsp;I can't find any sensible explanation to this phenomenon. It is the exact same length and the same symbols, and the numbers are meaningful observations as dates. Therefore,&amp;nbsp;I have no idea why the observations are being treated differently. &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Unavngivet.png" style="width: 291px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/23082i844AC219E9B8D4D7/image-size/large?v=v2&amp;amp;px=999" role="button" title="Unavngivet.png" alt="Unavngivet.png" /&gt;&lt;/span&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2018 14:36:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unknown-timeformat/m-p/493450#M129812</guid>
      <dc:creator>jbrau123</dc:creator>
      <dc:date>2018-09-07T14:36:02Z</dc:date>
    </item>
    <item>
      <title>Re: Unknown timeformat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unknown-timeformat/m-p/493457#M129815</link>
      <description>&lt;P&gt;That's because your incoming data contains an extra charater in the middle.&amp;nbsp; Assuming the extra character is a blank, try it this way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data Samlet6;&lt;/P&gt;
&lt;P&gt;set Samlet5;&lt;/P&gt;
&lt;P&gt;ansattid = compress(ansattid);&lt;/P&gt;
&lt;P&gt;ansattid2 = input(ansattid, yymmdd10.);&lt;/P&gt;
&lt;P&gt;format ansattid2 date9.;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If that doesn't work because the extra character is a nonblank, use a more complex expression:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ansattid = compress(ansattid, '0123456789-', 'k');&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The "k" instructs COMPRESS to keep (rather than remove) the designated characters.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2018 14:48:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unknown-timeformat/m-p/493457#M129815</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-09-07T14:48:28Z</dc:date>
    </item>
    <item>
      <title>Re: Unknown timeformat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unknown-timeformat/m-p/493460#M129816</link>
      <description>&lt;P&gt;You probably have some "hidden" characters in those files.&amp;nbsp; Could be just leading spaces that would cause the first 10 characters to not look like a valid date.&amp;nbsp; You could try using STRIP() function to remove leading/trailing spaces.&lt;/P&gt;
&lt;P&gt;Otherwise print the values using $HEX function and figure out what is in there.&amp;nbsp; Could be things like carriage return, 0D, line feed, 0A, tab, 09, non-breaking space, A0, null, 00.&amp;nbsp; It could also be that the hyphens are not actually hyphens, but en or em dash characters.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2018 14:48:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unknown-timeformat/m-p/493460#M129816</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-09-07T14:48:35Z</dc:date>
    </item>
    <item>
      <title>Re: Unknown timeformat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unknown-timeformat/m-p/493461#M129817</link>
      <description>&lt;P&gt;I'm sorry, but that doesn't seem to fix it, and I checked with edit mode&amp;nbsp;that there are no extra blank characters&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2018 14:49:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unknown-timeformat/m-p/493461#M129817</guid>
      <dc:creator>jbrau123</dc:creator>
      <dc:date>2018-09-07T14:49:51Z</dc:date>
    </item>
  </channel>
</rss>

