DATA Step, Macro, Functions and more

how to create a dataset from systemdate

Reply
Contributor
Posts: 45

how to create a dataset from systemdate

System date is 03/03/2011

I want to create a dataset like A
DATE
02-03-2011
01-03-2011
28-02-2011
27-02-2011
26-02-2011
25-02-2011

Kindly help me
Frequent Contributor
Posts: 82

Re: how to create a dataset from systemdate

Hi,

Try this:

%macro datelist;
data date_list (keep=date);
sysdate=%sysfunc(date());
format date date9.;
%do i=1 %to 6;
date=sysdate-&i;
output;
%end;
run;
%mend;
%datelist;
Contributor
Posts: 45

Re: how to create a dataset from systemdate

how to convert it into checracter data type
Frequent Contributor
Posts: 82

Re: how to create a dataset from systemdate

Usin Ksharp's code which is more simple to get character value:

data A;
do i=1 to 10;
date=put(put(today() - i, ddmmyyd10.), $10.);
output;
end;
drop i;
run;
Contributor
Posts: 45

Re: how to create a dataset from systemdate

Thanks a lot ieva and Ksharp for ur kind information
Super User
Posts: 10,028

Re: how to create a dataset from systemdate

[pre]
data A;
do i=1 to 10;
date=today() - i;
output;
end;
format date ddmmyyd10.;
drop i;
run;
[/pre]


Ksharp
Ask a Question
Discussion stats
  • 5 replies
  • 169 views
  • 0 likes
  • 3 in conversation