- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
My date is date=20361;
I need my date format to be in YYYYMMDD format.
I tried to use this format YMMDDxw. format
Piece of code :-
data _null_;
tdy_date = put(date, yymmddn8.);
call symput('today_dt', tdy_date);
run;
data _null_;
file output_&today_dt.;
set output_ds;
run;
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Then it'll depend on how you created your macro variable, but issues it the same, you're not passing the date to the function correctly.
tdy_date = put(&date, yymmddn8.);
It could be as simple as adding the & in front of your macro variable name.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Unless you have a variable date, this doesn't create anything, but since you don't have a SET statement, you don't have any variables.
tdy_date = put(date, yymmddn8.);
Were you intending to use TODAY() to return today's date?
tdy_date = put(today(), yymmddn8.);
@GunnerEP wrote:
My date is date=20361;
I need my date format to be in YYYYMMDD format.
I tried to use this format YMMDDxw. format
Piece of code :-
data _null_;
tdy_date = put(date, yymmddn8.);
call symput('today_dt', tdy_date);
run;
data _null_;
file output_&today_dt.;
set output_ds;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Yes i do have a variable date passed from script. & its not today literally, the date is read from a file. So it can be date which is like 4 days back as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@GunnerEP Where is the date then? In another data set, in a macro variable? Maybe you need to add the SET statement to make the data available.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Then it'll depend on how you created your macro variable, but issues it the same, you're not passing the date to the function correctly.
tdy_date = put(&date, yymmddn8.);
It could be as simple as adding the & in front of your macro variable name.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data _null_;
tdy_date = put(date(), yymmddn8.); /* use the function date() here */
call symput('today_dt', tdy_date);
run;
data _null_;
file output_&today_dt.; /* do you have a fileref output_20180323 ? */
/* if not, you probably should use double quotes and a file extension */
set output_ds;
/* without a put statement, nothing will be written to the file */
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Date is retrieved from a macro variable. To determine the tdy_date.
I do have a file ref, i am getting my output its just that the date variable is not getting resolved in the file name.
& i have put statement as well.( apologies missed out when i copied it here).
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Don't force us to make guesses. Post your REAL code. And example data for the dataset from which you retrieve the date.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content