- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Greetings all. I'm trying to create an empty dataset with today's date, in date9 format at the beginning of the name, but I can't figure out how to do it. Any help would be greatly appreciated.
%Let today = %sysfunc(date(),date9.);
data otbr."&today_otbr";
length DT_BILL $10.;
length CD_CYCLE BILL_COUNT 8.;
length AT_BILL 8.2.;
run;
----------------------------------------------------------------------------
WARNING: Apparent symbolic reference TODAY_OTBR not resolved.
7984 data otbr."&today_otbr";
-----
22
201
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, /, ;,
_DATA_, _LAST_, _NULL_.
ERROR 201-322: The option is not recognized and will be ignored.
7985 length DT_BILL $10.;
7986 length CD_CYCLE BILL_COUNT 8.;
7987 length AT_BILL 8.2.;
---
352
-
22
200
ERROR 352-185: The length of numeric variables is 3-8.
ERROR 22-322: Syntax error, expecting one of the following: a name, ;, DEFAULT, _ALL_,
_CHARACTER_, _CHAR_, _NUMERIC_.
ERROR 200-322: The symbol is not recognized and will be ignored.
7988 run;
ERROR: The value &TODAY_OTBR is not a valid SAS name.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
dataset name can't starting with number.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
From what I can see,
1, you are missing a '.', Try adding it on:
2. Length statement can only take 3-8, not 8.2, that is for format, change that. Also, for numeric variables, the default length is 8, so you can skip all of your length statement.
%Let today = %sysfunc(date(),date9.);
data otbr._&today._otbr;
length DT_BILL $10.;
run;
Haikuo
Update:
3. You can NOT name your table starting with a number. Add something like '_' in front of it.
4. Using quote in data statement will causing error, it is completely unnecessary.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Haikuo,
Why did you use "" in "&today._otbr"?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Right, I overlook that part. Quote is completely unnecessary. Will update my initial response.
Haikuo
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I don't think is a good idea to use "today" as a macro variable.
%Let dsn = %sysfunc(date(),date9.);
data otbr._&dsn._otbr;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
On a side note, I would suggest you switch from DATE9 to YYMMDDN8. If you are creating a series of data sets, consider what the names will look like. If you use YYMMDDN8 then the alphabetical order will match the order by creation date.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I'm getting closer.
%Let today = %sysfunc(date(),date9.);
data otbr.&today._OTBR;
length DT_BILL $10.;
length CD_CYCLE BILL_COUNT AT_BILL 8.;
run;
This creates the table, but it is creating it in the work library, not otbr. Also, the name is not how I think the macro variable is resolving. In the log I see these lines...
8233 %Let today = %sysfunc(date(),date9.);
8234 data otbr.&today._OTBR;
NOTE: Line generated by the macro variable "TODAY".
1 otbr.12SEP2012_OTBR
That makes me think the dataset to be created will be named 12SEP2012_OTBR, and it will be created in the otbr library. However, when the table is actually created, it is named Sep2012_otbr, and it is in the work library. Any ideas?
Greg
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
In fact, I don't even need the variable. This does the *exact* same thing...
data otbr.%sysfunc(date(),date9.)_otbr;
length DT_BILL $10.;
length CD_CYCLE BILL_COUNT AT_BILL 8.;
run;
Still putting it in my work library for some reason.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
dataset name can't starting with number.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
DOH!!! I should have know that, since the same is true for SQL Server. Thank you so much for that.