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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

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
  • 1 reply
  • 1628 views
  • 0 likes
  • 2 in conversation