<?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 chain format and type changes in Proc SQL? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-chain-format-and-type-changes-in-Proc-SQL/m-p/434511#M281946</link>
    <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table want as
select put(purchase_date,yymmn6.) as purchase_date
from have
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 06 Feb 2018 12:07:32 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-02-06T12:07:32Z</dc:date>
    <item>
      <title>How to chain format and type changes in Proc SQL?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-chain-format-and-type-changes-in-Proc-SQL/m-p/434510#M281945</link>
      <description>&lt;P&gt;I'm trying to chain format changes to go from a date in Date9. format to a character variable which will be the year-month variable of the same date. For example, starting from&amp;nbsp;05OCT2017 (date type), I want to end up with 201710.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't want do this with intermediary data steps and I want to do it in PROC SQL while avoiding subqueries as well.&lt;/P&gt;&lt;P&gt;It seemed natural to try the following, but this syntax isn't valid. How do I do this?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Create table want as
Select put(purchase_date format=YYMMN6., YYMMN6.)
  From have
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2018 11:59:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-chain-format-and-type-changes-in-Proc-SQL/m-p/434510#M281945</guid>
      <dc:creator>Autotelic</dc:creator>
      <dc:date>2018-02-06T11:59:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to chain format and type changes in Proc SQL?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-chain-format-and-type-changes-in-Proc-SQL/m-p/434511#M281946</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table want as
select put(purchase_date,yymmn6.) as purchase_date
from have
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Feb 2018 12:07:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-chain-format-and-type-changes-in-Proc-SQL/m-p/434511#M281946</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-02-06T12:07:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to chain format and type changes in Proc SQL?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-chain-format-and-type-changes-in-Proc-SQL/m-p/434513#M281947</link>
      <description>Even though I don't understand it, it works.&lt;BR /&gt;I thought the second parameter in the put() function should be how one wants to read the first parameter, but the first parameter is Date9., so, in my mind, trying to read Date9. as YYMMN6. should yield a missing value.</description>
      <pubDate>Tue, 06 Feb 2018 12:15:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-chain-format-and-type-changes-in-Proc-SQL/m-p/434513#M281947</guid>
      <dc:creator>Autotelic</dc:creator>
      <dc:date>2018-02-06T12:15:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to chain format and type changes in Proc SQL?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-chain-format-and-type-changes-in-Proc-SQL/m-p/434517#M281948</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/163649"&gt;@Autotelic&lt;/a&gt; wrote:&lt;BR /&gt;Even though I don't understand it, it works.&lt;BR /&gt;I thought the second parameter in the put() function should be how one wants to read the first parameter, but the first parameter is Date9., so, in my mind, trying to read Date9. as YYMMN6. should yield a missing value.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You're confusing the put() and the input() function. input() reads, while put() displays. Therefore you also need display formats for put(), but informats for input().&lt;/P&gt;
&lt;P&gt;In your case, the date value in the original variable purchase_date is "displayed" in the yymmn6. format, and the resulting character string stored in the new variable which is also named purchase_date.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2018 12:48:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-chain-format-and-type-changes-in-Proc-SQL/m-p/434517#M281948</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-02-06T12:48:03Z</dc:date>
    </item>
  </channel>
</rss>

