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).
Can you post the exact code, that doesn't look correct.
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)
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.
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)
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.
@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.
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!
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.