<?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: Update/fix the date in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Update-fix-the-date/m-p/10045#M878</link>
    <description>look at the on-line doc for the put function, and format DTYEAR.&lt;BR /&gt;
 &lt;BR /&gt;
From a datetime value it will return the "year".&lt;BR /&gt;
 &lt;BR /&gt;
If you want to extend your learning, look at PROC FORMAT where you can define you own format which would use the DTyear format for time-stamps in your "valid" range and '1980' for all other time-stamp values.&lt;BR /&gt;
 &lt;BR /&gt;
With that user format created as VldYr. your code would reduce to&lt;BR /&gt;
 &lt;BR /&gt;
DATA film_years ;&lt;BR /&gt;
SET DENTAL2_2 ;&lt;BR /&gt;
year = put( FILMDATE, vldYr. ) ;&lt;BR /&gt;
RUN; &lt;BR /&gt;
 &lt;BR /&gt;
PROC PRINT DATA= film_years ;&lt;BR /&gt;
   where year = '1980' ;&lt;BR /&gt;
RUN; &lt;BR /&gt;
 &lt;BR /&gt;
Alternatively, eliminate the data step with enhanced where statement like:&lt;BR /&gt;
PROC PRINT DATA= film_years ;&lt;BR /&gt;
   where put( FILMDATE, vldYr. ) = '1980' ;&lt;BR /&gt;
RUN;</description>
    <pubDate>Tue, 27 Apr 2010 16:51:23 GMT</pubDate>
    <dc:creator>Peter_C</dc:creator>
    <dc:date>2010-04-27T16:51:23Z</dc:date>
    <item>
      <title>Update/fix the date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Update-fix-the-date/m-p/10041#M874</link>
      <description>I am running the data set. It has dates where the year is not within the specified range so for those dates, I want to replace the incorrect year with the value 1977 (which is the mid year for cycle=3). So basically I want to update FILMDATE with 1977 as the year. How do I do that?&lt;BR /&gt;
&lt;BR /&gt;
DATA INCORRECT1_3;&lt;BR /&gt;
SET DENTAL1_2;&lt;BR /&gt;
DATE=DATEPART(FILMDATE);&lt;BR /&gt;
YEAR=YEAR(DATE);&lt;BR /&gt;
WHERE CYCLE=3;&lt;BR /&gt;
IF (YEAR LT 1975) OR (YEAR GT 1980) THEN *UPDATE FILMDATE WITH YEAR 1977;;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
PROC PRINT DATA=INCORRECT1_3;&lt;BR /&gt;
RUN;</description>
      <pubDate>Mon, 26 Apr 2010 15:34:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Update-fix-the-date/m-p/10041#M874</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-04-26T15:34:03Z</dc:date>
    </item>
    <item>
      <title>Re: Update/fix the date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Update-fix-the-date/m-p/10042#M875</link>
      <description>Assuming FilmDate is a date-time value, what month year and time should default for those cases you want to replace with year=1977?</description>
      <pubDate>Mon, 26 Apr 2010 17:22:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Update-fix-the-date/m-p/10042#M875</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-04-26T17:22:13Z</dc:date>
    </item>
    <item>
      <title>Re: Update/fix the date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Update-fix-the-date/m-p/10043#M876</link>
      <description>Assuming FilmDate is a date-time value, what month year and time should default for those cases you want to replace with year=1977? &lt;BR /&gt;
Yes, FILMDATE is date-time value. I want the new FILMDATE variable to have only the date (no time component) with the year 1977.</description>
      <pubDate>Mon, 26 Apr 2010 19:21:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Update-fix-the-date/m-p/10043#M876</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-04-26T19:21:16Z</dc:date>
    </item>
    <item>
      <title>Re: Update/fix the date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Update-fix-the-date/m-p/10044#M877</link>
      <description>Forget the earlier posts. The YEAR column shows 1980, which is what I want. Now I want DATE to show 1980 as well. How do I do that?&lt;BR /&gt;
&lt;BR /&gt;
DATA INCORRECT2;&lt;BR /&gt;
LENGTH TMISSING $ 8;&lt;BR /&gt;
SET DENTAL2_2;&lt;BR /&gt;
DATE=DATEPART(FILMDATE);&lt;BR /&gt;
YEAR=YEAR(DATE);&lt;BR /&gt;
FORMAT DATE DATE9.;&lt;BR /&gt;
IF (YEAR LT 1978) OR (YEAR GT 1982);&lt;BR /&gt;
IF (YEAR LT 1978) THEN YEAR=1980;&lt;BR /&gt;
IF (YEAR GT 1982) THEN YEAR=1980;&lt;BR /&gt;
RUN;&lt;BR /&gt;
PROC PRINT DATA=INCORRECT2;&lt;BR /&gt;
RUN;</description>
      <pubDate>Tue, 27 Apr 2010 16:07:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Update-fix-the-date/m-p/10044#M877</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-04-27T16:07:27Z</dc:date>
    </item>
    <item>
      <title>Re: Update/fix the date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Update-fix-the-date/m-p/10045#M878</link>
      <description>look at the on-line doc for the put function, and format DTYEAR.&lt;BR /&gt;
 &lt;BR /&gt;
From a datetime value it will return the "year".&lt;BR /&gt;
 &lt;BR /&gt;
If you want to extend your learning, look at PROC FORMAT where you can define you own format which would use the DTyear format for time-stamps in your "valid" range and '1980' for all other time-stamp values.&lt;BR /&gt;
 &lt;BR /&gt;
With that user format created as VldYr. your code would reduce to&lt;BR /&gt;
 &lt;BR /&gt;
DATA film_years ;&lt;BR /&gt;
SET DENTAL2_2 ;&lt;BR /&gt;
year = put( FILMDATE, vldYr. ) ;&lt;BR /&gt;
RUN; &lt;BR /&gt;
 &lt;BR /&gt;
PROC PRINT DATA= film_years ;&lt;BR /&gt;
   where year = '1980' ;&lt;BR /&gt;
RUN; &lt;BR /&gt;
 &lt;BR /&gt;
Alternatively, eliminate the data step with enhanced where statement like:&lt;BR /&gt;
PROC PRINT DATA= film_years ;&lt;BR /&gt;
   where put( FILMDATE, vldYr. ) = '1980' ;&lt;BR /&gt;
RUN;</description>
      <pubDate>Tue, 27 Apr 2010 16:51:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Update-fix-the-date/m-p/10045#M878</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-04-27T16:51:23Z</dc:date>
    </item>
    <item>
      <title>Re: Update/fix the date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Update-fix-the-date/m-p/10046#M879</link>
      <description>Alternatively, eliminate the data step with enhanced where statement like:&lt;BR /&gt;
PROC PRINT DATA= film_years ;&lt;BR /&gt;
where put( FILMDATE, vldYr. ) = '1980' ;&lt;BR /&gt;
RUN; &lt;BR /&gt;
&lt;BR /&gt;
I can try that. One question though, how will this PROC PRINT step know to take from data set DENTAL1_2?</description>
      <pubDate>Tue, 27 Apr 2010 17:02:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Update-fix-the-date/m-p/10046#M879</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-04-27T17:02:36Z</dc:date>
    </item>
    <item>
      <title>Re: Update/fix the date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Update-fix-the-date/m-p/10047#M880</link>
      <description>I mean DENTAL2_2.</description>
      <pubDate>Tue, 27 Apr 2010 17:03:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Update-fix-the-date/m-p/10047#M880</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-04-27T17:03:07Z</dc:date>
    </item>
    <item>
      <title>Re: Update/fix the date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Update-fix-the-date/m-p/10048#M881</link>
      <description>where the data comes from is defined by the DATA= option of the PROC PRINT statement, So you identified my error. (It was not intentional, just wrong). &lt;BR /&gt;
The print step might work better, defined like[pre] PROC PRINT DATA= DENTAL2_2 ;&lt;BR /&gt;
    where put( FILMDATE, vldYr. ) = '1980' ;&lt;BR /&gt;
 RUN; [/pre]but you still have to create the format VldYr with PROC FORMAT. The on-line doc for PROC FORMAT has relevant "Example 3: Writing a Format for Dates Using a Standard SAS Format"  at &lt;A href="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a002473487.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a002473487.htm&lt;/A&gt; (of course, your inputs are date-time values rather than date values, so you will be using date-time constants in the VALUE statement ranges == more &lt;B&gt;good SAS learning&lt;/B&gt;&lt;BR /&gt;
 &lt;BR /&gt;
PeterC</description>
      <pubDate>Tue, 27 Apr 2010 19:27:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Update-fix-the-date/m-p/10048#M881</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-04-27T19:27:37Z</dc:date>
    </item>
    <item>
      <title>Re: Update/fix the date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Update-fix-the-date/m-p/10049#M882</link>
      <description>Okay, I get that but for PROC FORMAT, what do I put for VALUE statement? I want the year of DATE variable to show as 1980 so how do I write that in VALUE statement?</description>
      <pubDate>Tue, 27 Apr 2010 20:54:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Update-fix-the-date/m-p/10049#M882</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-04-27T20:54:43Z</dc:date>
    </item>
    <item>
      <title>Re: Update/fix the date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Update-fix-the-date/m-p/10050#M883</link>
      <description>the purpose of the user-format I propose is to convert a timestamp to a year - either the year of the timestamp or 1980.&lt;BR /&gt;
  78 - 82 are valid years = use DYyear. format&lt;BR /&gt;
  other should be set to constant 1980&lt;BR /&gt;
Because your "filmDate" variable is a timestamp, you need to use a range of timestamp constants for the valid years.&lt;BR /&gt;
It is worth looking up the doc for "dt" constants.&lt;BR /&gt;
Here is how it is used in a VALUE statement &lt;BR /&gt;
VALUE VldYr (round) &lt;BR /&gt;
     "1jan1978:0:0"dt - '31Dec1982:23:59:59.999'dt  = [dtyear4.]&lt;BR /&gt;
     other = '1980'&lt;BR /&gt;
 ;&lt;BR /&gt;
you can do the rest from the manusl</description>
      <pubDate>Tue, 27 Apr 2010 21:20:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Update-fix-the-date/m-p/10050#M883</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-04-27T21:20:14Z</dc:date>
    </item>
    <item>
      <title>Re: Update/fix the date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Update-fix-the-date/m-p/10051#M884</link>
      <description>To update a SAS DATE variable (change the year-portion), you can look at using either the MDY function (after extracting the MONTH and DAY using these same-named functions in a DATA step.  Also, the INTNX function may be suitable if you are looking to increment/decrement the year portion -- using the "SAMEDAY" argument with INTNX.&lt;BR /&gt;
&lt;BR /&gt;
Check the SAS DOC (online and at the SAS support website) for these functions.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Tue, 27 Apr 2010 21:44:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Update-fix-the-date/m-p/10051#M884</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-04-27T21:44:00Z</dc:date>
    </item>
    <item>
      <title>Re: Update/fix the date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Update-fix-the-date/m-p/10052#M885</link>
      <description>I'm new to SAS so what you suggested seem complicated for me. Is there a simpler way to do it? I only want to replace 1980 for all years in DATE variable....</description>
      <pubDate>Tue, 27 Apr 2010 22:00:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Update-fix-the-date/m-p/10052#M885</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-04-27T22:00:58Z</dc:date>
    </item>
    <item>
      <title>Re: Update/fix the date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Update-fix-the-date/m-p/10053#M886</link>
      <description>Have you looked at using the SAS DATA step and IF/THEN &lt;ASSIGNMENT&gt;;  statement processing to perform data manipulation with SAS?  It's not so complicated.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
Suggested Google advanced search arguments, this topic/post:&lt;BR /&gt;
&lt;BR /&gt;
introduction data step programming site:sas.com&lt;BR /&gt;
&lt;BR /&gt;
mdy function data variables site:sas.com&lt;/ASSIGNMENT&gt;</description>
      <pubDate>Tue, 27 Apr 2010 22:47:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Update-fix-the-date/m-p/10053#M886</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-04-27T22:47:48Z</dc:date>
    </item>
    <item>
      <title>Re: Update/fix the date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Update-fix-the-date/m-p/10054#M887</link>
      <description>I got the YEAR to show me 1980, I want all DATE entries to update its year to 1980 so... what if I do DDMM1980.?</description>
      <pubDate>Wed, 28 Apr 2010 01:04:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Update-fix-the-date/m-p/10054#M887</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-04-28T01:04:07Z</dc:date>
    </item>
    <item>
      <title>Re: Update/fix the date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Update-fix-the-date/m-p/10055#M888</link>
      <description>You need to take a serious look at the SAS Language Elements DOC, specifically the functions YEAR, MONTH, DAY (extract the date components as assigned variables), and also MDY (used to create a SAS variable - here is where you can supply a year-value as the third argument).&lt;BR /&gt;
&lt;BR /&gt;
Suggest you work up a SAS program, test it, and then come back to the forum for feedback, if you have challenges.&lt;BR /&gt;
&lt;BR /&gt;
Tip: use the PUTLOG _ALL_;  command in your DATA step to display all variable values in the SAS log.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Wed, 28 Apr 2010 01:36:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Update-fix-the-date/m-p/10055#M888</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-04-28T01:36:42Z</dc:date>
    </item>
    <item>
      <title>Re: Update/fix the date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Update-fix-the-date/m-p/10056#M889</link>
      <description>DATA INCORRECT1_3;&lt;BR /&gt;
SET DENTAL1_2;&lt;BR /&gt;
DATE=DATEPART(FILMDATE);&lt;BR /&gt;
YEAR=YEAR(DATE);&lt;BR /&gt;
WHERE CYCLE=3;&lt;BR /&gt;
IF (YEAR LT 1975) OR (YEAR GT 1980) THEN &lt;BR /&gt;
newdt = input(cat(substr(put(date, date9.), 1, 5), '1977'), date9.);&lt;BR /&gt;
put newdt date9.;&lt;BR /&gt;
run;</description>
      <pubDate>Wed, 28 Apr 2010 13:31:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Update-fix-the-date/m-p/10056#M889</guid>
      <dc:creator>Flip</dc:creator>
      <dc:date>2010-04-28T13:31:07Z</dc:date>
    </item>
  </channel>
</rss>

