<?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: date in character and numeric format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/date-in-character-and-numeric-format/m-p/606140#M175979</link>
    <description>&lt;P&gt;You can use the RENAME= dataset option when reading the dataset to rename to numeric variables to a different name.&amp;nbsp; Then you can convert them into character in the step that combines, rather than modifying each dataset before combining them.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have have1(rename=(date=date_num)) ;
  if missing(date) and not missing(date_num)) then date=put(date_num,date9.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can query the metadata on your source datasets to determine which ones need the rename= option added.&lt;/P&gt;</description>
    <pubDate>Thu, 21 Nov 2019 14:22:30 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-11-21T14:22:30Z</dc:date>
    <item>
      <title>date in character and numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-in-character-and-numeric-format/m-p/606081#M175955</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have many raw data sets having date under same variable name in character and numeric format. How to set dates by changing all dates into character format without changing separately in each raw datasets&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For eg;&lt;/P&gt;&lt;P&gt;in libraw.have has date&amp;nbsp; in character format&amp;nbsp;&lt;/P&gt;&lt;P&gt;in libraw.have1 has date in numeric format&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;while setting&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have have1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;am getting error.since there are many datasets not able to find and chnage all numeric into character fomrat&lt;/P&gt;&lt;P&gt;similarly i have many datasets&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2019 11:37:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-in-character-and-numeric-format/m-p/606081#M175955</guid>
      <dc:creator>Aayushi_17</dc:creator>
      <dc:date>2019-11-21T11:37:41Z</dc:date>
    </item>
    <item>
      <title>Re: date in character and numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-in-character-and-numeric-format/m-p/606083#M175957</link>
      <description>You can try to rename the date variables in each dataset and convert the date from numeric to character in the datasets with numeric variable with the same name, then if you set the datasets you will not get any error.</description>
      <pubDate>Thu, 21 Nov 2019 11:59:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-in-character-and-numeric-format/m-p/606083#M175957</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-11-21T11:59:02Z</dc:date>
    </item>
    <item>
      <title>Re: date in character and numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-in-character-and-numeric-format/m-p/606086#M175959</link>
      <description>&lt;P&gt;Correct your import process, so that you get consistent structure in your datasets. Fixing it after the fact is unnecessary extra work.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2019 12:10:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-in-character-and-numeric-format/m-p/606086#M175959</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-11-21T12:10:58Z</dc:date>
    </item>
    <item>
      <title>Re: date in character and numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-in-character-and-numeric-format/m-p/606101#M175960</link>
      <description>&lt;P&gt;I agree with &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; , who presents the best solution. But sometimes us data analysts don't really control the process, the input data is in Excel and we have no choice here but to use the Excel file. If that's the case (and this has not been stated by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/245051"&gt;@Aayushi_17&lt;/a&gt;) then you would most likely need to write a macro to loop over all the SAS data sets and make the necessary changes.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2019 12:52:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-in-character-and-numeric-format/m-p/606101#M175960</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-11-21T12:52:21Z</dc:date>
    </item>
    <item>
      <title>Re: date in character and numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-in-character-and-numeric-format/m-p/606140#M175979</link>
      <description>&lt;P&gt;You can use the RENAME= dataset option when reading the dataset to rename to numeric variables to a different name.&amp;nbsp; Then you can convert them into character in the step that combines, rather than modifying each dataset before combining them.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have have1(rename=(date=date_num)) ;
  if missing(date) and not missing(date_num)) then date=put(date_num,date9.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can query the metadata on your source datasets to determine which ones need the rename= option added.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2019 14:22:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-in-character-and-numeric-format/m-p/606140#M175979</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-21T14:22:30Z</dc:date>
    </item>
    <item>
      <title>Re: date in character and numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-in-character-and-numeric-format/m-p/606237#M176027</link>
      <description>&lt;P&gt;This bit of code may help. It will list all dataset names (actually members so if you have VIEWS they will appear as well) in the library LIBRAW that have a variable named "DATE". The result will have the data set name as row header and columns labeled 'char' or 'num' for character and numeric with a 1 indicating which type the variable is in that set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Proc tabulate data=sashelp.vcolumn;
   where libname='LIBRAW' and upcase(name)='DATE';
   class memname type;
   tables memname,
          type*n=' '
          ;
run;&lt;/PRE&gt;
&lt;P&gt;I would usually suggest that any "date" be an actual SAS date numeric value with an appropriate date format applied.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have a good back up of the data, maybe copy the entire library for back up you might consider using some code similar to this:&lt;/P&gt;
&lt;PRE&gt;data _null_;
   set sashelp.vcolumn;
   where libname='LIBRAW' and upcase(name)='DATE' and type='char';
   length str $ 45;
   str = catx('.',libname,memname);
   call execute('data '|| str||';');
   call execute('set '|| str||' (rename=(date=chardate));');
   /* put your favorite standard date format below*/
   call execute('   date=input(chardate,anydtdte.);
   format date yymmdd10.;
   drop chardate;
   run;');
run;&lt;/PRE&gt;
&lt;P&gt;Which barring misfortune would make new copies of all of the data sets with the date as a numeric value formatted using the yymmdd10. format (or which ever format you replace in the code.&lt;/P&gt;
&lt;P&gt;CALL execute places text in to an execution queue and the argument to the function is a string value that evaluates to appropriate code.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2019 18:06:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-in-character-and-numeric-format/m-p/606237#M176027</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-11-21T18:06:14Z</dc:date>
    </item>
  </channel>
</rss>

