<?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 Convert column type from character to numeric in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Convert-column-type-from-character-to-numeric/m-p/480900#M124308</link>
    <description>&lt;P&gt;When I import a SAS table, there is a column with date and time like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;date_time&lt;/P&gt;&lt;P&gt;11JUN18:20:19:14&lt;/P&gt;&lt;P&gt;12JUN18:14:04:28&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This column has type: Date with length $8.&lt;/P&gt;&lt;P&gt;How can I convert this column into a column with type:character?&lt;/P&gt;&lt;P&gt;Since I need to use find function later to separate this data set into several weekly data sets.&lt;/P&gt;&lt;P&gt;The format of output can be just like above or like "11JUN18" without the time.&lt;/P&gt;</description>
    <pubDate>Tue, 24 Jul 2018 19:00:52 GMT</pubDate>
    <dc:creator>y_fu</dc:creator>
    <dc:date>2018-07-24T19:00:52Z</dc:date>
    <item>
      <title>Convert column type from character to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-column-type-from-character-to-numeric/m-p/480900#M124308</link>
      <description>&lt;P&gt;When I import a SAS table, there is a column with date and time like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;date_time&lt;/P&gt;&lt;P&gt;11JUN18:20:19:14&lt;/P&gt;&lt;P&gt;12JUN18:14:04:28&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This column has type: Date with length $8.&lt;/P&gt;&lt;P&gt;How can I convert this column into a column with type:character?&lt;/P&gt;&lt;P&gt;Since I need to use find function later to separate this data set into several weekly data sets.&lt;/P&gt;&lt;P&gt;The format of output can be just like above or like "11JUN18" without the time.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jul 2018 19:00:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-column-type-from-character-to-numeric/m-p/480900#M124308</guid>
      <dc:creator>y_fu</dc:creator>
      <dc:date>2018-07-24T19:00:52Z</dc:date>
    </item>
    <item>
      <title>Re: Convert column type from character to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-column-type-from-character-to-numeric/m-p/480903#M124310</link>
      <description>&lt;P&gt;You can't convert a numeric variable to character, or vice versa.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can create a new variable from your date_time that is character, but your justification is weak ("&lt;SPAN&gt;Since I need to use find function later to separate this data set into several weekly data sets")&lt;/SPAN&gt;, and this is not a good thing to do. It would be easier to separate this data into several weekly data sets if you left it as numeric. The INTCK function makes this very simple if you have a numeric variable. I can't even imagine separating data into weekly data sets if it is a character variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And you'd even be better off not separating the data into different data sets at all and then keep it as one big data set and use a BY statement when you do the analysis.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jul 2018 19:10:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-column-type-from-character-to-numeric/m-p/480903#M124310</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-07-24T19:10:12Z</dc:date>
    </item>
    <item>
      <title>Re: Convert column type from character to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-column-type-from-character-to-numeric/m-p/480907#M124311</link>
      <description>&lt;P&gt;But the time are all different within the same date.&lt;/P&gt;&lt;P&gt;For example, if I want to analyse data from 10JUN18 to 23JUN2018, what should I do?&lt;/P&gt;&lt;P&gt;I cannot use if then since the time are all different.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jul 2018 19:18:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-column-type-from-character-to-numeric/m-p/480907#M124311</guid>
      <dc:creator>y_fu</dc:creator>
      <dc:date>2018-07-24T19:18:37Z</dc:date>
    </item>
    <item>
      <title>Re: Convert column type from character to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-column-type-from-character-to-numeric/m-p/480910#M124313</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/222061"&gt;@y_fu&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;But the time are all different within the same date.&lt;/P&gt;
&lt;P&gt;For example, if I want to analyse data from 10JUN18 to 23JUN2018, what should I do?&lt;/P&gt;
&lt;P&gt;I cannot use if then since the time are all different.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I'm not sure what this means. Why is the time a problem? But nevertheless, the INTCK function makes all of this simple. And I did not suggest you use "if then".&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jul 2018 19:27:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-column-type-from-character-to-numeric/m-p/480910#M124313</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-07-24T19:27:32Z</dc:date>
    </item>
    <item>
      <title>Re: Convert column type from character to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-column-type-from-character-to-numeric/m-p/480912#M124314</link>
      <description>&lt;P&gt;1. A length of $8 reflects a character variable not a numerical variable, &lt;STRONG&gt;so verify your type vs format vs length&lt;/STRONG&gt;. Not sure what makes you think it is numeric. SAS only has two types, numeric and character, a date variable is numeric with a date format.&lt;/P&gt;
&lt;P&gt;2. It should be stored as a number with an appropriate format to enable better usage such as date intervals or applying a format to get summary statistics easily.&lt;/P&gt;
&lt;P&gt;3. To group your data, a character conversion won't help you since the time will still be different. Rather use a Date format or DATEPART () function to extract only the date portion of the date time variable and use that in your calculations instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/222061"&gt;@y_fu&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;But the time are all different within the same date.&lt;/P&gt;
&lt;P&gt;For example, if I want to analyse data from 10JUN18 to 23JUN2018, what should I do?&lt;/P&gt;
&lt;P&gt;I cannot use if then since the time are all different.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jul 2018 19:25:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-column-type-from-character-to-numeric/m-p/480912#M124314</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-07-24T19:25:54Z</dc:date>
    </item>
    <item>
      <title>Re: Convert column type from character to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-column-type-from-character-to-numeric/m-p/480915#M124315</link>
      <description>&lt;P&gt;Importing SAS table or Importing external file into SAS? If your file is Excel and using proc import then, I would suggest you to convert it into CSV and read the data using&amp;nbsp; DATA step INFILE which you will have more control over the data types.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jul 2018 19:27:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-column-type-from-character-to-numeric/m-p/480915#M124315</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-07-24T19:27:58Z</dc:date>
    </item>
  </channel>
</rss>

