<?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: Replacing observations for date variable with wrong formatting from stata in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Replacing-observations-for-date-variable-with-wrong-formatting/m-p/489928#M128042</link>
    <description>&lt;P&gt;Are you sure the values are actually **** or is the way that you are looking at it just showing that because the actual value is too large?&lt;/P&gt;
&lt;P&gt;The only way the value could be *** is if the variable is a character string instead of a date.&lt;/P&gt;
&lt;P&gt;Look at the actual unformatted values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 26 Aug 2018 19:38:15 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2018-08-26T19:38:15Z</dc:date>
    <item>
      <title>Replacing observations for date variable with wrong formatting from stata</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-observations-for-date-variable-with-wrong-formatting/m-p/489923#M128040</link>
      <description>&lt;P&gt;I imported a stata dataset into SAS successfully. However, for my date variable (r24_date), several of the observations had typos such that 16oct2015&amp;nbsp;is actually coded as16oct&lt;U&gt;02&lt;/U&gt;15. I can see this when looking at the stata dataset in stata. Something goes wrong here when I import the stata dataset into SAS and "16oct0215" becomes *&lt;SPAN&gt;*********.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class="branch"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, printing out a single observation (after sorting the dataset by r24_date ascending):&amp;nbsp;&lt;/P&gt;&lt;DIV class="branch"&gt;&lt;DIV align="center"&gt;&lt;DIV class="branch"&gt;&lt;DIV align="center"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sas1.PNG" style="width: 237px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/22781i36429C75A9C44744/image-size/large?v=v2&amp;amp;px=999" role="button" title="sas1.PNG" alt="sas1.PNG" /&gt;&lt;/span&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Other than this one date typo, the remainder of the dates are correct and are in the format MMDDYY10.&lt;/P&gt;&lt;P&gt;For example:&amp;nbsp;&lt;/P&gt;&lt;DIV class="branch"&gt;&lt;DIV align="center"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sas2.PNG" style="width: 228px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/22782i4FB42BD8558FCE55/image-size/large?v=v2&amp;amp;px=999" role="button" title="sas2.PNG" alt="sas2.PNG" /&gt;&lt;/span&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried to replace the ******** using a simple datastep, but SAS does not like the **********s.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data&amp;nbsp;want;&amp;nbsp;&lt;BR /&gt;set have;&lt;/P&gt;&lt;P&gt;if r24_date = "**********" then r24_date = "16oct2015"d;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried changing the data in stata and in excel then importing to SAS, but I am still having errors related to date formats.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any thoughts? Thanks.&amp;nbsp;&lt;/P&gt;&lt;DIV class="branch"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="branch"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Sun, 26 Aug 2018 17:37:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-observations-for-date-variable-with-wrong-formatting/m-p/489923#M128040</guid>
      <dc:creator>ly2105</dc:creator>
      <dc:date>2018-08-26T17:37:51Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing observations for date variable with wrong formatting from stata</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-observations-for-date-variable-with-wrong-formatting/m-p/489928#M128042</link>
      <description>&lt;P&gt;Are you sure the values are actually **** or is the way that you are looking at it just showing that because the actual value is too large?&lt;/P&gt;
&lt;P&gt;The only way the value could be *** is if the variable is a character string instead of a date.&lt;/P&gt;
&lt;P&gt;Look at the actual unformatted values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 26 Aug 2018 19:38:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-observations-for-date-variable-with-wrong-formatting/m-p/489928#M128042</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-08-26T19:38:15Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing observations for date variable with wrong formatting from stata</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-observations-for-date-variable-with-wrong-formatting/m-p/489929#M128043</link>
      <description>&lt;P&gt;Thanks for the tip- you're correct.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I looked at it with no formatting applied and in fact&amp;nbsp;the value is -637060. Using the following code was successful in changing the values.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want; 
	set have; 
	if r24_date = -637060 then r24_date = "16oct2015"d; 
run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;DIV class="branch"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Sun, 26 Aug 2018 19:50:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-observations-for-date-variable-with-wrong-formatting/m-p/489929#M128043</guid>
      <dc:creator>ly2105</dc:creator>
      <dc:date>2018-08-26T19:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing observations for date variable with wrong formatting from stata</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-observations-for-date-variable-with-wrong-formatting/m-p/489930#M128044</link>
      <description>&lt;P&gt;SAS does not accept dates in year 215.&amp;nbsp; There are so many changes to calendars that it is not really straight forward how to represent them as integers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But that value does look like something that might be in the year 215.&lt;/P&gt;
&lt;PRE&gt;292  data x;
293   x=-637060 ;
294   month=month(x);
295   day=day(x);
296   year=year(x);
297   year2=1960-int(-x/365);
298   put (_all_) (=);
299  run;

NOTE: Invalid argument to function MONTH(-637060) at line 294 column 8.
NOTE: Invalid argument to function DAY(-637060) at line 295 column 6.
NOTE: Invalid argument to function YEAR(-637060) at line 296 column 7.
x=-637060 month=. day=. year=. year2=215
x=-637060 month=. day=. year=. year2=215 _ERROR_=1 _N_=1
NOTE: Mathematical operations could not be performed at the following places. The results of the
      operations have been set to missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      1 at 294:8   1 at 295:6   1 at 296:7
NOTE: The data set WORK.X has 1 observations and 5 variables.&lt;/PRE&gt;</description>
      <pubDate>Sun, 26 Aug 2018 20:05:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-observations-for-date-variable-with-wrong-formatting/m-p/489930#M128044</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-08-26T20:05:39Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing observations for date variable with wrong formatting from stata</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-observations-for-date-variable-with-wrong-formatting/m-p/490152#M128158</link>
      <description>&lt;P&gt;Any date that might be considered as prior to 1518, The English adoption of the Gregorian calendar will yield an invalid date and the SAS formats will display the ********** you saw.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have a "year" greater than 9999 then SAS will display the year portion of the format as **** or **&lt;/P&gt;</description>
      <pubDate>Mon, 27 Aug 2018 16:19:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-observations-for-date-variable-with-wrong-formatting/m-p/490152#M128158</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-08-27T16:19:39Z</dc:date>
    </item>
  </channel>
</rss>

