BookmarkSubscribeRSS Feed
abak
Obsidian | Level 7

Just gained ownership over some sas code that is not working at current:

 

data step has a merge statement that references a "master.sas7bdat" data set the following way:

 

merge msa$f..master(in = b);

 

where $f = module

 

However, the location of the file is ~msa/module/data and it returns with an error that there is no libname defined as msamodule.

 

Long story short-I am lost on how to properly specify the path, (and I don't know why the code suddenly broke when I gained ownership over this issue either).

6 REPLIES 6
Reeza
Super User

Can you post the exact code, that doesn't look correct. 

abak
Obsidian | Level 7

You are both right. The code uses a & not a $.

 

Exact Code:

 

data _null_;
   call symput("f","module");
run;

 

 

data cleanmaster2;
merge msa&f..master(in=b)

ballardw
Super User

Are you sure the character $ in this code is what is actually in the code file?

 

merge msa$f..master(in = b);

 

I would more likely expect to see

 

merge msa&f..master(in = b);

 

which would expect the presence of a macro variable named F whose value is used to reference an existing library whose name starts with the letters MSA among a number of libraries. A further clue is the two periods in the statement as that is proper for used of a macro variable followed by an element that should contain a period such as the separator between a library name and the data set.

 

Suppose I had SAS libraries named:

msanew

msaold

msatest.

 

If I execute

%let f = new; assigning a value to a macro variable named f, then

msa&f  would resolve to msanew when used only as a library reference and

msa&f..master would resolve to msanew.master where a data set name was needed.

 

 

abak
Obsidian | Level 7

Yes, as stated above for the other contributor: THe code is

 

data _null_;
   call symput("f","module");
run;

 

 

data cleanmaster2;
merge msa&f..master(in=b)

 

....etc

 

But I still don't know how to specify the path msa/module/data.master.sas (master is the name of the sas data set I need to pull in)

 

 

Reeza
Super User

Look for something like the following:

 

libname msa&f 'path to folder here';

That sets the path to the msa folder and is what you need to change.

 

ballardw
Super User

@abak wrote:

 

data _null_;
   call symput("f","module");
run;

 

data cleanmaster2;
merge msa&f..master(in=b)

 

....etc

 

 


this code, and a Libname statement using msa&f will generate errors. Library names are limited to 8 characters.

msamodule would be 9 characters and hence invalid.

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!

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
  • 6 replies
  • 3187 views
  • 0 likes
  • 3 in conversation