BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
gsnidow
Obsidian | Level 7

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


1 ACCEPTED SOLUTION

Accepted Solutions
Linlin
Lapis Lazuli | Level 10

dataset name can't starting with number.

View solution in original post

9 REPLIES 9
Haikuo
Onyx | Level 15

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.

Linlin
Lapis Lazuli | Level 10

Haikuo,

Why did you use "" in "&today._otbr"?

Haikuo
Onyx | Level 15

Right, I overlook that part. Quote is completely unnecessary. Will update my initial response.

Haikuo

Linlin
Lapis Lazuli | Level 10

I don't think is a good idea to use "today" as a macro variable.

%Let dsn = %sysfunc(date(),date9.);

data otbr._&dsn._otbr;

Astounding
PROC Star

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.

gsnidow
Obsidian | Level 7

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

gsnidow
Obsidian | Level 7

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.

Linlin
Lapis Lazuli | Level 10

dataset name can't starting with number.

gsnidow
Obsidian | Level 7

DOH!!!  I should have know that, since the same is true for SQL Server.  Thank you so much for that.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 9 replies
  • 9824 views
  • 4 likes
  • 4 in conversation