<?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 Change Type and Format of a Variable Without Renaming? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-Change-Type-and-Format-of-a-Variable-Without-Renaming/m-p/531218#M145358</link>
    <description>&lt;P&gt;Your code worked.&lt;/P&gt;
&lt;P&gt;Did you notice the small icon at the top of the column?&lt;/P&gt;
&lt;P&gt;You now have a SAS date and not a string.&lt;/P&gt;
&lt;P&gt;One thing you must change: you have a same column name twice, which is of course impossible. Use:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select ID, input(YEARMONTH,yymmn6.) as YEARMONTH format=date9.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 30 Jan 2019 00:36:36 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2019-01-30T00:36:36Z</dc:date>
    <item>
      <title>How to Change Type and Format of a Variable Without Renaming?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Change-Type-and-Format-of-a-Variable-Without-Renaming/m-p/531214#M145355</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have one more simple question. I want to change the type and format of Yearmonth variable without changing its name in PROC SQL Actually, I was thinking that I&amp;nbsp; am writing the correct code however, nothing has changed. Can somebody help me to create my desired format for the variable YearMonth, please?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Have;
Input  ID YEARMONTH $;
Datalines;
1 201606
1 201607
1 201608
1 201609
1 201610
1 201611
1 201612
1 201701
1 201702
1 201703
1 201704
1 201705
;
Run;
PROC SQL;
CREATE TABLE WANT AS
SELECT *,Input(YEARMONTH,YYMMN6.) AS YEARMONTH Format=date9.
FROM Have;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Desired;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DES.png" style="width: 211px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/26688iEC25EA9AF2FC4E05/image-size/large?v=v2&amp;amp;px=999" role="button" title="DES.png" alt="DES.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jan 2019 00:02:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Change-Type-and-Format-of-a-Variable-Without-Renaming/m-p/531214#M145355</guid>
      <dc:creator>turcay</dc:creator>
      <dc:date>2019-01-30T00:02:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to Change Type and Format of a Variable Without Renaming?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Change-Type-and-Format-of-a-Variable-Without-Renaming/m-p/531217#M145357</link>
      <description>&lt;P&gt;You shouldn't use * and then name a var with the same name&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
CREATE TABLE WANT AS
SELECT id,Input(YEARMONTH,YYMMN6.) AS YEARMONTH Format=date9.
FROM Have;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note:&lt;/P&gt;
&lt;P&gt;1. Using *, you tell SQL processor to select all columns from the input table, which means the compiler has already got that to process.&lt;/P&gt;
&lt;P&gt;2. Ideally, you should be using proc datasets to reassign formats rather than reading the file&lt;/P&gt;
&lt;P&gt;3. If you want to just play with metadata, why bother reading the data portion&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jan 2019 00:38:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Change-Type-and-Format-of-a-Variable-Without-Renaming/m-p/531217#M145357</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-01-30T00:38:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to Change Type and Format of a Variable Without Renaming?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Change-Type-and-Format-of-a-Variable-Without-Renaming/m-p/531218#M145358</link>
      <description>&lt;P&gt;Your code worked.&lt;/P&gt;
&lt;P&gt;Did you notice the small icon at the top of the column?&lt;/P&gt;
&lt;P&gt;You now have a SAS date and not a string.&lt;/P&gt;
&lt;P&gt;One thing you must change: you have a same column name twice, which is of course impossible. Use:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select ID, input(YEARMONTH,yymmn6.) as YEARMONTH format=date9.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jan 2019 00:36:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Change-Type-and-Format-of-a-Variable-Without-Renaming/m-p/531218#M145358</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-01-30T00:36:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to Change Type and Format of a Variable Without Renaming?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Change-Type-and-Format-of-a-Variable-Without-Renaming/m-p/531219#M145359</link>
      <description>&lt;P&gt;Thank you for your response.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But what if I have more than one variable. For example, what if I have 300 variables in my data set, should I write them one by one ?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jan 2019 00:38:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Change-Type-and-Format-of-a-Variable-Without-Renaming/m-p/531219#M145359</guid>
      <dc:creator>turcay</dc:creator>
      <dc:date>2019-01-30T00:38:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to Change Type and Format of a Variable Without Renaming?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Change-Type-and-Format-of-a-Variable-Without-Renaming/m-p/531220#M145360</link>
      <description>&lt;P&gt;in that case, renaming using dataset option is a good idea&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
CREATE TABLE WANT(drop=ym) AS
SELECT *,Input(ym,YYMMN6.) AS YEARMONTH Format=date9.
FROM Have(rename=(yearmonth=ym));
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Jan 2019 00:43:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Change-Type-and-Format-of-a-Variable-Without-Renaming/m-p/531220#M145360</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-01-30T00:43:20Z</dc:date>
    </item>
  </channel>
</rss>

