<?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: Convert variable data types from char to date in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-variable-data-types-from-char-to-date/m-p/900721#M43896</link>
    <description>&lt;P&gt;Format statement does not recognize array references.&lt;/P&gt;
&lt;P&gt;However you can use a single format statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;format new_date:  date9.;&lt;/PRE&gt;
&lt;P&gt;anywhere in the data step.&lt;/P&gt;
&lt;P&gt;The colon is a list indicator and says "use all the variable names that start with New_date".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can simplify your code a little bit by using:&lt;/P&gt;
&lt;PRE&gt;Array new_date(50);&lt;/PRE&gt;
&lt;P&gt;That will create variables named New_date1 through New_date50 and you use New_date[i] .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 30 Oct 2023 15:52:04 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2023-10-30T15:52:04Z</dc:date>
    <item>
      <title>Convert variable data types from char to date</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-variable-data-types-from-char-to-date/m-p/900709#M43893</link>
      <description>I have a data set that has variables assign_date1 to assign_date50. They are date variables but in character format&lt;BR /&gt;E.g sample values - 2021-05-24 ; 2021-04-15&lt;BR /&gt;&lt;BR /&gt;I am trying to convert them to date using arrays and do loop. The date format that I want the values to be - 24MAY2021 ; 15APR2021. Below is the code that I am using&lt;BR /&gt;&lt;BR /&gt;Data test;&lt;BR /&gt;Set dataset ; /*data set sample name*:&lt;BR /&gt;&lt;BR /&gt;/* Existing date variables in character form*/&lt;BR /&gt;Array assign_date_array(50) $ 10&lt;BR /&gt;Assign_date1-Assign_date50;&lt;BR /&gt;&lt;BR /&gt;/*Variables that would store the converted date variables*/&lt;BR /&gt;&lt;BR /&gt;Array new_date_array(50)&lt;BR /&gt;New_date1-New_date50;&lt;BR /&gt;&lt;BR /&gt;Do I =1 to 50;&lt;BR /&gt;&lt;BR /&gt;New_date_array[i] = input(assign_date_array[i] , yymmdd10.);&lt;BR /&gt;&lt;BR /&gt;Format new_date_array[i] date9.;&lt;BR /&gt;End;&lt;BR /&gt;Drop I;&lt;BR /&gt;Run;&lt;BR /&gt;&lt;BR /&gt;Code runs when I exclude the format line. But as soon as I execute with format line I get error 85-232- Expecting a format name&lt;BR /&gt;&lt;BR /&gt;The code runs fine when I run with individual Column name I.e not with do loop and array&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 30 Oct 2023 15:33:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-variable-data-types-from-char-to-date/m-p/900709#M43893</guid>
      <dc:creator>Sam22</dc:creator>
      <dc:date>2023-10-30T15:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: Convert variable data types from char to date</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-variable-data-types-from-char-to-date/m-p/900715#M43894</link>
      <description>&lt;P&gt;I don't think the FORMAT statement accepts an array reference.&amp;nbsp; Remove the FORMAT statement from the loop, and just code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format Assign_date1-Assign_date50 date9.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Oct 2023 15:47:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-variable-data-types-from-char-to-date/m-p/900715#M43894</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2023-10-30T15:47:10Z</dc:date>
    </item>
    <item>
      <title>Re: Convert variable data types from char to date</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-variable-data-types-from-char-to-date/m-p/900717#M43895</link>
      <description>&lt;P&gt;FORMAT statements want the name(s) of the VARIABLES.&amp;nbsp; I cannot take an indirect reference to a variable since it it is not executable.&amp;nbsp; It just defines what format to attach to the vairable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  set dataset ;
  array assign_date [50] ;
  array new_date [50] ;
  format new_date1-new_date50 date9.;
  do I =1 to 50;
    new_date[i] = input(assign_date[i] , yymmdd10.);
  end;
  drop I;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Oct 2023 15:51:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-variable-data-types-from-char-to-date/m-p/900717#M43895</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-10-30T15:51:54Z</dc:date>
    </item>
    <item>
      <title>Re: Convert variable data types from char to date</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-variable-data-types-from-char-to-date/m-p/900721#M43896</link>
      <description>&lt;P&gt;Format statement does not recognize array references.&lt;/P&gt;
&lt;P&gt;However you can use a single format statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;format new_date:  date9.;&lt;/PRE&gt;
&lt;P&gt;anywhere in the data step.&lt;/P&gt;
&lt;P&gt;The colon is a list indicator and says "use all the variable names that start with New_date".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can simplify your code a little bit by using:&lt;/P&gt;
&lt;PRE&gt;Array new_date(50);&lt;/PRE&gt;
&lt;P&gt;That will create variables named New_date1 through New_date50 and you use New_date[i] .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Oct 2023 15:52:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-variable-data-types-from-char-to-date/m-p/900721#M43896</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-10-30T15:52:04Z</dc:date>
    </item>
  </channel>
</rss>

