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

Hi all, 

I want to add a version number to the dataset I generate. A version number contains dots. Is that allowed?

 

If so, how to get it done?

 

I tried this:

%let versionnr = v2.8;

%let eversionnr = %sysfunc(tranwrd(&versionnr,'.','p0.5'n));

 

data aa_&eversionnr;

aa = 1;

run;

 

But I get the error message:

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, /, ;, _DATA_, _LAST_, _NULL_. 

 

Thanks, kind regards,

Dimitri

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

The dot separator has specific meanings in SAS code depending on where used. So when you have a "name" like ABC.Anything on a Data, Set, Merge, Update, Modify or any place you intend to use a data set name the interpretation will be that ABC is LIBRARY and the data set name is Anything. If that is not a valid libname.dataset then you get errors.

 

Save some headache and use an _ for data sets instead of trying to use . and skip the whole name literal bit.

 

You should also show what you expect that generated name to look like. Your code as shown does not change that v2.8 because the macro language is looking for quotes as well. '.' does not occur in the Versionnr variable so nothing is translated.

530  %let versionnr = v2.8;
531  %let eversionnr = %sysfunc(tranwrd(&versionnr,'.','p0.5'n));
532
533  %put eversionnr is  &eversionnr.;
eversionnr is  v2.8

If your tranwrd actually "worked" using this:

534  %let versionnr = v2.8;
535  %let eversionnr = %sysfunc(tranwrd(&versionnr,.,'p0.5'n));
536
537  %put eversionnr is  &eversionnr.;
eversionnr is  v2'p0.5'n8

You have an even worse possible "data set name" that violates multiple rules. A name literal must start with quote and end with quote and N.

View solution in original post

1 REPLY 1
ballardw
Super User

The dot separator has specific meanings in SAS code depending on where used. So when you have a "name" like ABC.Anything on a Data, Set, Merge, Update, Modify or any place you intend to use a data set name the interpretation will be that ABC is LIBRARY and the data set name is Anything. If that is not a valid libname.dataset then you get errors.

 

Save some headache and use an _ for data sets instead of trying to use . and skip the whole name literal bit.

 

You should also show what you expect that generated name to look like. Your code as shown does not change that v2.8 because the macro language is looking for quotes as well. '.' does not occur in the Versionnr variable so nothing is translated.

530  %let versionnr = v2.8;
531  %let eversionnr = %sysfunc(tranwrd(&versionnr,'.','p0.5'n));
532
533  %put eversionnr is  &eversionnr.;
eversionnr is  v2.8

If your tranwrd actually "worked" using this:

534  %let versionnr = v2.8;
535  %let eversionnr = %sysfunc(tranwrd(&versionnr,.,'p0.5'n));
536
537  %put eversionnr is  &eversionnr.;
eversionnr is  v2'p0.5'n8

You have an even worse possible "data set name" that violates multiple rules. A name literal must start with quote and end with quote and N.

sas-innovate-white.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Early bird rate extended! Save $200 when you sign up by March 31.

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1819 views
  • 0 likes
  • 2 in conversation