<?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 Format change and string to numeric format change in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Date-Format-change-and-string-to-numeric-format-change/m-p/766128#M242758</link>
    <description>&lt;P&gt;So the FILINGDATE variable has mixed styles of how the dates are typed.&lt;/P&gt;
&lt;P&gt;Here is one way that seems to work with this example.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want1;
  set "c:\downloads\first";
  date = input(filingdate,??mmddyy10.);
  if missing(date) then date=input(filingdate,??date11.);
  format date yymmdd10.;
run;

proc freq ;
 tables date*filingdate/ list missing;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The variable CIK is the second variable in that CIK2 dataset.&lt;/P&gt;
&lt;P&gt;To change the length of a character variable you need to set the new length before data step compiler "sees" the old one.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want2;
   length cik $10 ;
   set "c:\downloads\chik2";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I would NOT convert CIK to numeric, you will loose the leading zeros.&lt;/P&gt;</description>
    <pubDate>Sun, 05 Sep 2021 16:03:20 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-09-05T16:03:20Z</dc:date>
    <item>
      <title>Date Format change and string to numeric format change</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Format-change-and-string-to-numeric-format-change/m-p/766114#M242750</link>
      <description>&lt;P&gt;Hi All&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two issues:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. The file attached named First has date format imported as string but I cannot change that to date numeric format&amp;nbsp;&lt;SPAN&gt;YYMMDDN8.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;2. The file attached named cik2 has 10 digit code v2 with zeros before 7 digit number. I want to transform this column from string to numeric but when I convert I keep loosing the zeros at the beginning of the number.&lt;/P&gt;&lt;P&gt;3. The v2 variable needs to have only 10 digit length but it has 79 charac space now.&lt;/P&gt;&lt;P&gt;All help is appreciated&lt;/P&gt;</description>
      <pubDate>Sun, 05 Sep 2021 13:54:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Format-change-and-string-to-numeric-format-change/m-p/766114#M242750</guid>
      <dc:creator>OzanKirtac</dc:creator>
      <dc:date>2021-09-05T13:54:05Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format change and string to numeric format change</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Format-change-and-string-to-numeric-format-change/m-p/766115#M242751</link>
      <description>&lt;P&gt;Character strings can be converted to numeric using the INPUT() function and the proper &lt;A href="https://documentation.sas.com/doc/en/pgmmvacdc/9.4/allprodslang/syntaxByType-informat.htm" target="_self"&gt;informat&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set first;
    filingdate1=input(filingdate,anydtdte10.);
    format filingdate1 yymmddd10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding CIK2 converting it to numeric, why bother? It is soooo much easier to leave it as character. Strings like this don't need to be numeric, because you are not going to compute a mean or sum of these values. So that's my answer, use it as character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;3. The v2 variable needs to have only 10 digit length but it has 79 charac space now.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is no v2 variable.&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>Sun, 05 Sep 2021 15:17:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Format-change-and-string-to-numeric-format-change/m-p/766115#M242751</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-09-05T15:17:51Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format change and string to numeric format change</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Format-change-and-string-to-numeric-format-change/m-p/766128#M242758</link>
      <description>&lt;P&gt;So the FILINGDATE variable has mixed styles of how the dates are typed.&lt;/P&gt;
&lt;P&gt;Here is one way that seems to work with this example.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want1;
  set "c:\downloads\first";
  date = input(filingdate,??mmddyy10.);
  if missing(date) then date=input(filingdate,??date11.);
  format date yymmdd10.;
run;

proc freq ;
 tables date*filingdate/ list missing;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The variable CIK is the second variable in that CIK2 dataset.&lt;/P&gt;
&lt;P&gt;To change the length of a character variable you need to set the new length before data step compiler "sees" the old one.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want2;
   length cik $10 ;
   set "c:\downloads\chik2";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I would NOT convert CIK to numeric, you will loose the leading zeros.&lt;/P&gt;</description>
      <pubDate>Sun, 05 Sep 2021 16:03:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Format-change-and-string-to-numeric-format-change/m-p/766128#M242758</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-09-05T16:03:20Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format change and string to numeric format change</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Format-change-and-string-to-numeric-format-change/m-p/766234#M242824</link>
      <description>&lt;P&gt;Thank you for the responses.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want the date in the following format 20220123 so yymmddN8.&amp;nbsp; must be the new format. so in the last linke format date&amp;nbsp;yymmddN8.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class="language-sas"&gt;&lt;CODE&gt;ata want1;
  set "c:\downloads\first";
  date = input(filingdate,??mmddyy10.);
  if missing(date) then date=input(filingdate,??date11.);
  format date yymmdd10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Sep 2021 15:53:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Format-change-and-string-to-numeric-format-change/m-p/766234#M242824</guid>
      <dc:creator>OzanKirtac</dc:creator>
      <dc:date>2021-09-06T15:53:48Z</dc:date>
    </item>
  </channel>
</rss>

