<?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 how to import empty columns as date instead of $1 characters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-import-empty-columns-as-date-instead-of-1-characters/m-p/708659#M217821</link>
    <description>&lt;P&gt;Hi SAS experts,&lt;BR /&gt;I'm new to SAS programming, could you please help with the following!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I've multiple date columns for a study and some of these date columns can be completely empty for all the rows, so while importing, SAS is importing these completely empty columns as length 1 characters. Since other dates are imported as dates and I'm not able to compare across these dates.&lt;/P&gt;&lt;P&gt;My sample data looks like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;id,date1,date2,date3
100,,,
101,10-10-2020,20-10-2020,
102,15-10-2020,,
103,,,&lt;/PRE&gt;&lt;P&gt;I'm trying to import this using&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import out= test
            datafile = "/home/one/sas/study_data.txt"
            dbms = CSV REPLACE ;
			delimiter=',';guessingrows=32767;
			DATAROW=2;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In the imported data, I'm seeing the date3 as character of length 1, so I'm not able to compare this date3 column with date2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way, we can tell SAS to import all the date columns (date1, date2, date3) as date columns of format YYMMDD10. even though some of these columns are completely empty and if the column isn't empty, it should import all the data in the format YYMMDD10.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a ton in advance!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 29 Dec 2020 23:00:50 GMT</pubDate>
    <dc:creator>chandanar</dc:creator>
    <dc:date>2020-12-29T23:00:50Z</dc:date>
    <item>
      <title>how to import empty columns as date instead of $1 characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-import-empty-columns-as-date-instead-of-1-characters/m-p/708659#M217821</link>
      <description>&lt;P&gt;Hi SAS experts,&lt;BR /&gt;I'm new to SAS programming, could you please help with the following!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I've multiple date columns for a study and some of these date columns can be completely empty for all the rows, so while importing, SAS is importing these completely empty columns as length 1 characters. Since other dates are imported as dates and I'm not able to compare across these dates.&lt;/P&gt;&lt;P&gt;My sample data looks like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;id,date1,date2,date3
100,,,
101,10-10-2020,20-10-2020,
102,15-10-2020,,
103,,,&lt;/PRE&gt;&lt;P&gt;I'm trying to import this using&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import out= test
            datafile = "/home/one/sas/study_data.txt"
            dbms = CSV REPLACE ;
			delimiter=',';guessingrows=32767;
			DATAROW=2;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In the imported data, I'm seeing the date3 as character of length 1, so I'm not able to compare this date3 column with date2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way, we can tell SAS to import all the date columns (date1, date2, date3) as date columns of format YYMMDD10. even though some of these columns are completely empty and if the column isn't empty, it should import all the data in the format YYMMDD10.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a ton in advance!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Dec 2020 23:00:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-import-empty-columns-as-date-instead-of-1-characters/m-p/708659#M217821</guid>
      <dc:creator>chandanar</dc:creator>
      <dc:date>2020-12-29T23:00:50Z</dc:date>
    </item>
    <item>
      <title>Re: how to import empty columns as date instead of $1 characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-import-empty-columns-as-date-instead-of-1-characters/m-p/708666#M217823</link>
      <description>&lt;P&gt;You say it yourself: all the rows are blank for the variable. So what's to compare.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Copy the code generated by proc import that will be in the log. Paste into the editor and clean up. Change the informat to match that of the "date" variables you do see.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are reading multiple similar files then a data step is a much better way to go. That way you set all the properties for the variables and can make them the same for different data sets. Just change the name of the source file on the INFILE statement and the name of the output data set.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Dec 2020 23:11:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-import-empty-columns-as-date-instead-of-1-characters/m-p/708666#M217823</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-12-29T23:11:03Z</dc:date>
    </item>
  </channel>
</rss>

