<?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: Importing data into SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Importing-data-into-SAS/m-p/423796#M280986</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input month$ day$	year$;
datalines;
1	0	22016
1	0	22016
1	0	32016
11	0	32016
1	1	52016
2	1	12016
3	0	82016
10	1	2016
3	0	82016
2	1	92016
;

data inter;
   set have;
   if length(year)=5 then do;
   day=cats(day, substr(year, 1, 1));
   year=substr(year, length(year)-3, 4);
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;.. And convert them to numeric &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 27 Dec 2017 21:03:57 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2017-12-27T21:03:57Z</dc:date>
    <item>
      <title>Importing data into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-data-into-SAS/m-p/423783#M280980</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to import a csv file into SAS. One of the variables DOB was created using the following variables: 1) month 2) day 3) year.&lt;/P&gt;&lt;P&gt;When I read it in SAS I used the following format: Month (.2) Day (.2) Year (.4). DOB (date9.). When it's done I noticed that DOB was calculated incorrectly so I went back to the csv file and realized the issue was with the csv file. For instance,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Month Day&amp;nbsp; &amp;nbsp; Year&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DOB&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;22016&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (should be 1/2/2016)&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;62016&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (should be 1/6/2016)&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;42016&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (should be 4/24/2016)&lt;/P&gt;&lt;P&gt;12&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;32016&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (should be 12/13/2016)&lt;/P&gt;&lt;P&gt;10&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2016&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;10/2/2016&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (how do I know if it is 10/2/2016 or 10/20/2016)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All I know is that the original data was a txt file and converted into csv by someone else. Unfortunately, I do not know how he/she did it also do not have access to the original text file. Can anyone help me how to resolve the issue here?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&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>Wed, 27 Dec 2017 19:55:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-data-into-SAS/m-p/423783#M280980</guid>
      <dc:creator>Kiko</dc:creator>
      <dc:date>2017-12-27T19:55:33Z</dc:date>
    </item>
    <item>
      <title>Re: Importing data into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-data-into-SAS/m-p/423786#M280981</link>
      <description>&lt;P&gt;So your issue is that part of the day variable is somehow included in the year variable?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you attach the csv file?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2017 20:01:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-data-into-SAS/m-p/423786#M280981</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-12-27T20:01:33Z</dc:date>
    </item>
    <item>
      <title>Re: Importing data into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-data-into-SAS/m-p/423787#M280982</link>
      <description>&lt;P&gt;Hi:&lt;BR /&gt; This would be easier to figure out if we could see the actual CSV file. For example, does the CSV file actually have this:&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;1,0,22016 &lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;1,0,62016&lt;/FONT&gt; &lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;OR does it have this:&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;1,02,2016 &lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;1,06,2016&lt;/STRONG&gt; &lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt; It could be a problem with the program you used to read the CSV file. But without the data or the program you used, it is hard to do more than guess.&lt;BR /&gt;&lt;BR /&gt;cynthia&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2017 20:04:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-data-into-SAS/m-p/423787#M280982</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2017-12-27T20:04:22Z</dc:date>
    </item>
    <item>
      <title>Re: Importing data into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-data-into-SAS/m-p/423790#M280983</link>
      <description>&lt;P&gt;Hi This is what the csv file looks like. Come to think of it that 10/1/2016 must have been 10/10/2016 otherwise I would have ended up with 10/0/12016 instead. Any comments would be much appreciated!&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;month&lt;/TD&gt;&lt;TD&gt;day&lt;/TD&gt;&lt;TD&gt;year&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;22016&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;22016&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;32016&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;11&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;32016&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;52016&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;12016&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;82016&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2016&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;82016&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;92016&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Wed, 27 Dec 2017 20:26:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-data-into-SAS/m-p/423790#M280983</guid>
      <dc:creator>Kiko</dc:creator>
      <dc:date>2017-12-27T20:26:01Z</dc:date>
    </item>
    <item>
      <title>Re: Importing data into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-data-into-SAS/m-p/423794#M280984</link>
      <description>&lt;P&gt;Here is one way you could correct the data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
  input month day year;
  cards;
1          0       22016
1          0       62016
4          2       42016
12        1       32016
10        2        2016
;
data want;
  set have;
  format dob date9.;
  if year gt 2018 then do;
    if day eq 0 then do;
      day=input(substr(put(year,5.),1,1),8.);
      year=input(substr(put(year,5.),2),8.);
    end;
    else do;
      day=input(catt(day,substr(put(year,5.),1,1)),8.);
      year=input(substr(put(year,5.),2),8.);
    end;
  end;
  dob=mdy(month,day,year);
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2017 20:54:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-data-into-SAS/m-p/423794#M280984</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-12-27T20:54:48Z</dc:date>
    </item>
    <item>
      <title>Re: Importing data into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-data-into-SAS/m-p/423795#M280985</link>
      <description>&lt;P&gt;Are these numeric or character variables?&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2017 20:56:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-data-into-SAS/m-p/423795#M280985</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-12-27T20:56:10Z</dc:date>
    </item>
    <item>
      <title>Re: Importing data into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-data-into-SAS/m-p/423796#M280986</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input month$ day$	year$;
datalines;
1	0	22016
1	0	22016
1	0	32016
11	0	32016
1	1	52016
2	1	12016
3	0	82016
10	1	2016
3	0	82016
2	1	92016
;

data inter;
   set have;
   if length(year)=5 then do;
   day=cats(day, substr(year, 1, 1));
   year=substr(year, length(year)-3, 4);
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;.. And convert them to numeric &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2017 21:03:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-data-into-SAS/m-p/423796#M280986</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-12-27T21:03:57Z</dc:date>
    </item>
    <item>
      <title>Re: Importing data into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-data-into-SAS/m-p/423802#M280987</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/135005"&gt;@Kiko&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi This is what the csv file looks like. Come to think of it that 10/1/2016 must have been 10/10/2016 otherwise I would have ended up with 10/0/12016 instead. Any comments would be much appreciated!&lt;/P&gt;
&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;month&lt;/TD&gt;
&lt;TD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;/BLOCKQUOTE&gt;
&lt;P&gt;CSV files normally don't look like that. They don't have lines drawn around the values like they were in spreadsheet or something.&amp;nbsp; Instead they have commas between the values, hence the name, comma-separated values.&amp;nbsp; A CSV version of that might look like this instead:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;month,day,year
1,0,22016
1,0,22016
1,0,32016
11,0,32016
1,1,52016
2,1,12016
3,0,82016
10,1,2016
3,0,82016
2,1,92016&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But taking your example data you can try to convert it back to a string of digits and then try to interpret those digits as representing a date in month day year order.&amp;nbsp;This version works for the data you posted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  set have ;
  dt=input(cats(month,day,year),mmddyy10.);
  format dt mmddyy10..;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But if your dataset that you posted has the YEAR variable as a number then it might have lost the leading zero in the YEAR value that was in the data. For example the eight value might have been like this instead in the source&amp;nbsp; file.&lt;/P&gt;
&lt;PRE&gt;10,1,02016&lt;/PRE&gt;
&lt;P&gt;But by being read as number instead of as a string the first digit in the YEAR value was lost. You could try adding it back by using the Z format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  set have ;
  dt1=input(cats(month,day,year),mmddyy10.);
  dt2=input(cats(month,day,put(year,z5.)),mmddyy10.);
  same  = dt1 = dt2 ;
  format dt: mmddyy10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 371px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/17544i866E59DF8CCB0636/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2017 21:52:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-data-into-SAS/m-p/423802#M280987</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-12-27T21:52:07Z</dc:date>
    </item>
    <item>
      <title>Re: Importing data into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-data-into-SAS/m-p/423804#M280988</link>
      <description>&lt;P&gt;They are numeric!&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2017 22:10:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-data-into-SAS/m-p/423804#M280988</guid>
      <dc:creator>Kiko</dc:creator>
      <dc:date>2017-12-27T22:10:28Z</dc:date>
    </item>
    <item>
      <title>Re: Importing data into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-data-into-SAS/m-p/423858#M280990</link>
      <description>&lt;P&gt;Thanks for providing the answer on importing data into SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://mindmajix.com/sas-training" target="_blank"&gt;https://mindmajix.com/sas-training&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Dec 2017 07:14:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-data-into-SAS/m-p/423858#M280990</guid>
      <dc:creator>azharuddin</dc:creator>
      <dc:date>2017-12-28T07:14:38Z</dc:date>
    </item>
  </channel>
</rss>

