<?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: Informat to only read in a year? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Informat-to-only-read-in-a-year/m-p/209141#M267279</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The reason I wanted a date format is because if I want to create a listing that has dates, and some have fully known dates, but some have UN-UNK-YYYY, and I want to use the same variable for both instances, where the variable I want to display is already a date format.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;if CMSTDAT = . &amp;amp; substr(CMSTDAT_P,1,1)='U' then CMSTDAT = input(substr(CMSTDAT_P,8,4),4.);&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The variable I want to use on my listing is CMSTDAT; however, the above code doesn't work because when I try to change the value of CMSTDAT (which is a blank numeric value, but CMSTDAT_P is a populated character value) it interprets the date wrong. Since SAS stores dates as the number of seconds away from Jan 1st 1960, could I convert the year value created from the input&amp;amp; substr functions by multiplying it out? If so how would I do that? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your reply!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 28 Aug 2015 23:08:46 GMT</pubDate>
    <dc:creator>tkallday33</dc:creator>
    <dc:date>2015-08-28T23:08:46Z</dc:date>
    <item>
      <title>Informat to only read in a year?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Informat-to-only-read-in-a-year/m-p/209135#M267273</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Howdy folks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Quick question that I can't seem to find an answer to. If I am substringing the year off of the MHDIAGYR_P variable like so:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;diagyrch = substr(MHDIAGYR_P,8,4);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;how would I then convert this diagyrch character variable to a numeric variable named diagyrnum?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying something like this....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;diagyrnum=input(diagyrch,date.);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I can't figure out what the correct informat to use is in my input function. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is an example value of MHDIAGYR_P:&amp;nbsp; UN-UNK-1984&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so diagyrch = 1984 but I want SAS to read that as the Orwellian nineteen eighty-four. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Tyler&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Aug 2015 23:33:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Informat-to-only-read-in-a-year/m-p/209135#M267273</guid>
      <dc:creator>tkallday33</dc:creator>
      <dc:date>2015-08-27T23:33:56Z</dc:date>
    </item>
    <item>
      <title>Re: Informat to only read in a year?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Informat-to-only-read-in-a-year/m-p/209136#M267274</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not sure you gain any value in having a SAS date versus a 4 digit number. &lt;/P&gt;&lt;P&gt;If you can't find an information consider using 4. to convert to numeric and then MDY to create a date. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Aug 2015 00:56:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Informat-to-only-read-in-a-year/m-p/209136#M267274</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-08-28T00:56:08Z</dc:date>
    </item>
    <item>
      <title>Re: Informat to only read in a year?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Informat-to-only-read-in-a-year/m-p/209137#M267275</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Easiest way :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;= substr(..) + 0;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Real programmers don't like the notes it generates, but to me it doesn't matter.&lt;/P&gt;&lt;P&gt;This "trick" also works in Excel &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another option : start with defining the diagyrch variable as numeric using a length statement.&lt;/P&gt;&lt;P&gt;length diagyrch 8;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Eric&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Aug 2015 06:50:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Informat-to-only-read-in-a-year/m-p/209137#M267275</guid>
      <dc:creator>EH</dc:creator>
      <dc:date>2015-08-28T06:50:55Z</dc:date>
    </item>
    <item>
      <title>Re: Informat to only read in a year?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Informat-to-only-read-in-a-year/m-p/209138#M267276</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;diagyrnum = input(substr(MHDIAGYR_P,8,4),4.);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Aug 2015 07:27:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Informat-to-only-read-in-a-year/m-p/209138#M267276</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2015-08-28T07:27:24Z</dc:date>
    </item>
    <item>
      <title>Re: Informat to only read in a year?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Informat-to-only-read-in-a-year/m-p/209139#M267277</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It WILL matter to you, once you've been bitten in the ass by the consequences of an implicit type cast.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any NOTE that goes beyond "dataset X created, with Y records and Z colums" raises a red flag with me.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Aug 2015 12:05:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Informat-to-only-read-in-a-year/m-p/209139#M267277</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2015-08-28T12:05:09Z</dc:date>
    </item>
    <item>
      <title>Re: Informat to only read in a year?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Informat-to-only-read-in-a-year/m-p/209140#M267278</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When doing a code review you have to check why all calculations generate errors/notes. This just adds to the list...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Aug 2015 14:29:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Informat-to-only-read-in-a-year/m-p/209140#M267278</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-08-28T14:29:50Z</dc:date>
    </item>
    <item>
      <title>Re: Informat to only read in a year?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Informat-to-only-read-in-a-year/m-p/209141#M267279</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The reason I wanted a date format is because if I want to create a listing that has dates, and some have fully known dates, but some have UN-UNK-YYYY, and I want to use the same variable for both instances, where the variable I want to display is already a date format.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;if CMSTDAT = . &amp;amp; substr(CMSTDAT_P,1,1)='U' then CMSTDAT = input(substr(CMSTDAT_P,8,4),4.);&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The variable I want to use on my listing is CMSTDAT; however, the above code doesn't work because when I try to change the value of CMSTDAT (which is a blank numeric value, but CMSTDAT_P is a populated character value) it interprets the date wrong. Since SAS stores dates as the number of seconds away from Jan 1st 1960, could I convert the year value created from the input&amp;amp; substr functions by multiplying it out? If so how would I do that? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your reply!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Aug 2015 23:08:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Informat-to-only-read-in-a-year/m-p/209141#M267279</guid>
      <dc:creator>tkallday33</dc:creator>
      <dc:date>2015-08-28T23:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: Informat to only read in a year?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Informat-to-only-read-in-a-year/m-p/209142#M267280</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can't change a variable type in place. &lt;/P&gt;&lt;P&gt;But you can create a new variable, but you have to assign a day/month to the year as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;if substr(CMSTDAT_P,1,1)='U' then CMSTDAT_DATE = mdy(1,1, input(substr(CMSTDAT_P,8,4),4.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;else &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;CMSTDAT_DATE&lt;/SPAN&gt;=input(cmstdat, date9.);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You might need to play around with that a bit as I'm not 100% sure what your data looks like. You may be better off posting a new question with what your data looks like and what you want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; line-height: 19px; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 29 Aug 2015 01:15:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Informat-to-only-read-in-a-year/m-p/209142#M267280</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-08-29T01:15:04Z</dc:date>
    </item>
  </channel>
</rss>

