Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

please help!

Status
Not open for further replies.

evaaseow

Programmer
Jan 25, 2007
29
CA
%macro test;
/*
%let to_day = input(%substr("07feb07",1,2),2.);
%let to_month = %substr("07feb07",3,3);
%let to_year = %substr("07feb07",6,2);
*/


proc sql;
select ccdate, ccend_date, DM_EXCLUDE_UNTIL_DATE
INTO : cstart separated by ' ',
: cend separated by ' ',
: cexclude separated by ' '
FROM work.temp
;
quit;

/* Get the from date */
DATA _NULL_;
CALL symput('temp_from_date',PUT(&cstart+7, date7.));
RUN;

%put temp_from_date = &temp_from_date;

proc sql;
update work.test
set cycle = put(input(cycle,1.) + 1,
ccdate = &temp_from_date;
quit;

%mend test;


i know this is wrong, can anyone help? what i'm trying to do is select a date from a table. using that date i would like to add 7 days and update that same table. how is this possible?
 
If the table is not a remote RDBMS table (ie if it is a SAS Dataset) I'd probably use datasteps rather than Proc SQL.
If all you're doing is adding 7 days to the date fields then you'd just need:-
Code:
data mydset;
  set mydset_old;

  date_field = date_field + 7;
run;
Or have I got the wrong end of the stick here?

I would recommend creating a copy of the dataset before updating it, or renaming it, and then recreating it. This allows you to re-run if necessary as well as checking results against the original data.



Chris
Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.
 
Hey Chris, thanks for the reply. I will try the datastep method. One question though, for date_field=date_field + 7, what would be the syntax if the date was formatted in 01/30/2007?
 
SAS doesn't have a "date" data type, a date is actually a count of the number of days since 1st of Jan 1960. The FORMAT of the date field is immaterial when working with it. The important thing to remember is that a format does not change the actual data, just how it is displayed to you.

Chris
Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top