<?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 proc import swaps day and month in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/proc-import-swaps-day-and-month/m-p/652973#M22481</link>
    <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I am trying to do some regression on datafile from here:&amp;nbsp;&lt;A href="https://www.kaggle.com/tsarkov90/crime-in-russia-20032020" target="_blank"&gt;https://www.kaggle.com/tsarkov90/crime-in-russia-20032020&lt;/A&gt;&lt;/P&gt;&lt;P&gt;However, I encounter a problem. I have tried to import the file using:&lt;/P&gt;&lt;P&gt;proc import datafile="&amp;lt;path&amp;gt;"&lt;BR /&gt;out=crime&lt;BR /&gt;dbms=csv&lt;BR /&gt;replace;&lt;BR /&gt;getnames=yes;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;The problem is, that it seems to swype month and day. I mean there are first 12 days of January and then next year. How can I fix this problem?&lt;/P&gt;&lt;P&gt;Also, for further analysis I'd like to retain only month/year. How can I do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks, cheers&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 03 Jun 2020 19:29:27 GMT</pubDate>
    <dc:creator>svzplayer</dc:creator>
    <dc:date>2020-06-03T19:29:27Z</dc:date>
    <item>
      <title>proc import swaps day and month</title>
      <link>https://communities.sas.com/t5/New-SAS-User/proc-import-swaps-day-and-month/m-p/652973#M22481</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I am trying to do some regression on datafile from here:&amp;nbsp;&lt;A href="https://www.kaggle.com/tsarkov90/crime-in-russia-20032020" target="_blank"&gt;https://www.kaggle.com/tsarkov90/crime-in-russia-20032020&lt;/A&gt;&lt;/P&gt;&lt;P&gt;However, I encounter a problem. I have tried to import the file using:&lt;/P&gt;&lt;P&gt;proc import datafile="&amp;lt;path&amp;gt;"&lt;BR /&gt;out=crime&lt;BR /&gt;dbms=csv&lt;BR /&gt;replace;&lt;BR /&gt;getnames=yes;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;The problem is, that it seems to swype month and day. I mean there are first 12 days of January and then next year. How can I fix this problem?&lt;/P&gt;&lt;P&gt;Also, for further analysis I'd like to retain only month/year. How can I do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks, cheers&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 19:29:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/proc-import-swaps-day-and-month/m-p/652973#M22481</guid>
      <dc:creator>svzplayer</dc:creator>
      <dc:date>2020-06-03T19:29:27Z</dc:date>
    </item>
    <item>
      <title>Re: proc import swaps day and month</title>
      <link>https://communities.sas.com/t5/New-SAS-User/proc-import-swaps-day-and-month/m-p/652974#M22482</link>
      <description>Don't use PROC IMPORT then, you'll need to write a data step to import the data. You can get the code from the log and change the variables needed and then re-run it.&lt;BR /&gt;&lt;BR /&gt;Another option is to try adding the guessingrows=max; option to it to see if it reads it correctly.</description>
      <pubDate>Wed, 03 Jun 2020 19:31:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/proc-import-swaps-day-and-month/m-p/652974#M22482</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-06-03T19:31:24Z</dc:date>
    </item>
    <item>
      <title>Re: proc import swaps day and month</title>
      <link>https://communities.sas.com/t5/New-SAS-User/proc-import-swaps-day-and-month/m-p/652978#M22483</link>
      <description>&lt;P&gt;The default behavior of reading dates of xx/yy/zz and whether XX is treated as month or day of month and YY the other is based on your current setting of your DATESTYLE option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can check what your current setting is with&lt;/P&gt;
&lt;PRE&gt;proc options option=datestyle;
run;&lt;/PRE&gt;
&lt;P&gt;The log will show something like&lt;/P&gt;
&lt;PRE&gt; DATESTYLE=MDY     Specifies the sequence of month, day, and year when ANYDTDTE, ANYDTDTM, or
                   ANYDTTME informat data is ambiguous.

&lt;/PRE&gt;
&lt;P&gt;Or you might see&amp;nbsp;&amp;nbsp; DMY for the order.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the order in the data is different than your setting then Import would swap the order of day and month from what is intended.&lt;/P&gt;
&lt;P&gt;You can fix this by a couple of methods.&lt;/P&gt;
&lt;P&gt;Set the option to the desired order with an Options datestyle= MDY(or DMY), which ever is needed.&lt;/P&gt;
&lt;P&gt;Don't forget to set it the Datestyle option back to your current afterwards or other things may misbehave.&lt;/P&gt;
&lt;P&gt;Or Proc import would have created data step code in the log. Copy the code and clean it up removing line numbers and such. Then&lt;/P&gt;
&lt;P&gt;find the INFORMAT statement for the variable(s) of interest and change them to read the data properly. I can't see the data a the link you provided so I would guess that an informat of either MMDDYY10. or DDMMYY10. (depending on whether month or day comes first) might work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is not need to change the date values once created to do analysis by year and month only. You can assign a format to a variable that will create groups usable by any of the SAS analysis procedures. Likely candidates would by YYMMN6. to create groups like 201906 (June 2019) or YYMON7. if you want something like 2019JUN displayed.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 19:49:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/proc-import-swaps-day-and-month/m-p/652978#M22483</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-03T19:49:07Z</dc:date>
    </item>
    <item>
      <title>Re: proc import swaps day and month</title>
      <link>https://communities.sas.com/t5/New-SAS-User/proc-import-swaps-day-and-month/m-p/652980#M22484</link>
      <description>&lt;P&gt;Alright, I have followed your suggestion writing:&lt;/P&gt;&lt;P&gt;data crime;&lt;BR /&gt;infile "&amp;lt;path&amp;gt;" DLM=',' FIRSTOBS=2;&lt;BR /&gt;input month $ Total_crimes Serious Huge_damage Ecological Terrorism&lt;BR /&gt;Extremism Murder Harm_to_health Rape Theft Vehicle_theft&lt;BR /&gt;Fraud_scam Hooligan Drugs Weapons;&lt;BR /&gt;format month DDMMYY10.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;And... Another problem.&lt;/P&gt;&lt;P&gt;I attach two photos - first results with proc import and 2nd with this data step procedure. Seems like all years are cut on the first 2 digits.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;lt;sorry for such a long reply, however I could not upload either .png or .jpg&amp;gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 20:01:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/proc-import-swaps-day-and-month/m-p/652980#M22484</guid>
      <dc:creator>svzplayer</dc:creator>
      <dc:date>2020-06-03T20:01:58Z</dc:date>
    </item>
    <item>
      <title>Re: proc import swaps day and month</title>
      <link>https://communities.sas.com/t5/New-SAS-User/proc-import-swaps-day-and-month/m-p/652981#M22485</link>
      <description>&lt;P&gt;Sorry if the link is inaccessible &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, date is in format dd/mm/yyyy so I guess it's DDMMYY10. . Here is a funny thing, I followed your instructions and log shows that I have set dmy. However, when I run proc contents, it shows MMDDYY10. in the particular cell. In a reply for a previous answer, I have attached results from proc import and data step. I hope it can help somehow, because I run out of ideas...&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 20:05:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/proc-import-swaps-day-and-month/m-p/652981#M22485</guid>
      <dc:creator>svzplayer</dc:creator>
      <dc:date>2020-06-03T20:05:00Z</dc:date>
    </item>
    <item>
      <title>Re: proc import swaps day and month</title>
      <link>https://communities.sas.com/t5/New-SAS-User/proc-import-swaps-day-and-month/m-p/652983#M22486</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/328523"&gt;@svzplayer&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Alright, I have followed your suggestion writing:&lt;/P&gt;
&lt;P&gt;data crime;&lt;BR /&gt;infile "&amp;lt;path&amp;gt;" DLM=',' FIRSTOBS=2;&lt;BR /&gt;input month $ Total_crimes Serious Huge_damage Ecological Terrorism&lt;BR /&gt;Extremism Murder Harm_to_health Rape Theft Vehicle_theft&lt;BR /&gt;Fraud_scam Hooligan Drugs Weapons;&lt;BR /&gt;format month DDMMYY10.;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;And... Another problem.&lt;/P&gt;
&lt;P&gt;I attach two photos - first results with proc import and 2nd with this data step procedure. Seems like all years are cut on the first 2 digits.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;lt;sorry for such a long reply, however I could not upload either .png or .jpg&amp;gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You did not tell SAS to read the value as a date and a simple $ input such as : input month $ only reads 8 characters.&lt;/P&gt;
&lt;P&gt;Try this data step:&lt;/P&gt;
&lt;PRE&gt;data crime;
   infile "&amp;lt;path&amp;gt;" DLM=',' FIRSTOBS=2;
   informat month ddmmyy10.
   input month  Total_crimes Serious Huge_damage Ecological Terrorism
            Extremism Murder Harm_to_health Rape Theft Vehicle_theft
            Fraud_scam Hooligan Drugs Weapons;
   format month DDMMYY10.;
run;&lt;/PRE&gt;
&lt;P&gt;And as I mention in my other post, you may want to use the YYMMN6. format .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 20:14:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/proc-import-swaps-day-and-month/m-p/652983#M22486</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-03T20:14:17Z</dc:date>
    </item>
    <item>
      <title>Re: proc import swaps day and month</title>
      <link>https://communities.sas.com/t5/New-SAS-User/proc-import-swaps-day-and-month/m-p/653030#M22494</link>
      <description>&lt;P&gt;Thank you very much!&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 00:04:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/proc-import-swaps-day-and-month/m-p/653030#M22494</guid>
      <dc:creator>svzplayer</dc:creator>
      <dc:date>2020-06-04T00:04:10Z</dc:date>
    </item>
  </channel>
</rss>

