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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 2054 views
  • 0 likes
  • 2 in conversation