Hi to all,
sorry for my very dummy questions but I'm newbie user at first steps with sas programming.
Can anyone tell me what does this macro code fragment?
%let lib_mylib=&scan(myLib,1,.); data &lib_mylib..start_somethings; field=''; run;
MyLib is a registered sas library that point to database schema oracle.
My doubt is on ".." (dot dot) characher in data step label (&lib_mylib..start_somethings).
I googled for long time but I not found anything.
Can anyone help me to understand what means?
thanks in advance.
@vinpres wrote:
Sorry, I suspect that we are going out of the topic.
The code that I showed in the above post is only as example and introduction for my questions.
Precisely, my question is:
Physically where I find the persistent dataset named that we create through a code like above?
Is a persistent dataset stored in a file of the filesystems?
Or is it stored in a metadata table like sql table?
So, where I find physically the persistent dataset named start_somethings? In the database or filesystem directory?
thanks.
It depends.
If your libref is a simple SAS library that is pointing to a physical directory.
libname mylib '/mydirecotry';
Then the dataset referenced by MYLIB.FRED is a physical file name fred.sas7bdat in the physical directory named /mydirectory. Note that the extension used by SAS on the files that are SAS datasets have changed over the years and could change again in the future, but have consistently been sas7bdat for a number of years.
Now if MYLIB is using some other libref engine then you need to check that engine for how it works. If it is Oracle then it is a table in the schema that you pointed the libref to. If it is the XLSX engine the it is a sheet in the workbook that you pointed the libref to.
Hi @vinpres
In the %LET statement, you declare a macrovariable lib_mylib and assign the value myLib to it.
You can then refer to this macrovariable in the next steps of your program by using an ampersand (&) and a dot (.) : &lib_mylib.
So here, writing &lib_mylib..start_somethings is strictly equivalent to writing mylib.start_somethings, which refers to the dataset start_somethings in the SAS library mylib that you may have defined in a LIBNAME statement)
You can see the macrovariable as a kind of 'alias', meaning that if you change the value of the macrovariable in the %LET statement, SAS will automatically update the reference in the program.
%let lib_mylib=myLib; data &lib_mylib..start_somethings; field=''; run;
Hope it's clear.
Best,
Just a precision:
if you omit the double dot (&lib_mylib.start_somethings), SAS will look for the dataset mylibstart_somethings in the WORK library as no library is specified.
Best,
thanks for the response.
Ok, perfect. It' very clear what you say and your explanation explanation has reassured me.
But I have yet a doubt related to the dataser start_somethings at the right of &lib_mylib.
I searched anywhere, on database, sas library, file system but I have found nothing about it.
thanks in advance.
Your %let statement as posted will result in a WARNING:
WARNING: Apparent symbolic reference SCAN not resolved. 72 73 %let lib_mylib=&scan(myLib,1,.);
because you mistakenly used the ampersand instead of the percent sign when you tried to call the %SCAN macro function.
Since your new macro variable is assigned the text as-is , it still causes the WARNING when displayed_
74 %put &lib_mylib.; WARNING: Apparent symbolic reference SCAN not resolved. &scan(myLib,1,.)
So you need to first fix that:
%let lib_mylib=%scan(myLib,1,.);
but this won't work either, as the text "myLib" contains no dot, so there's nothing to split with %SCAN:
73 %let lib_mylib=%scan(myLib,1,.); 74 %put &lib_mylib.; myLib
So I guess you wanted to use a macro variable instead:
%let lib_mylib=%scan(&myLib.,1,.);
But to see if this is can work as intended, we need to see how macro variable myLib is defined in the first place.
Once your new macro variable lib_mylib holds a correct value, the following
data &lib_mylib..start_somethings;
field='';
run;
would create a new dataset there named start_somethings, with one variable (field) and one observation where field is empty.
Thanks a lot to both of you for the explanation.
But physically where I find the persistent dataset named start_somethings?
Is a persistent dataset stored in a file of the filesystems?
Or is it stored in a metadata table like sql table?
So, my question is: where I find physically the persistent dataset named start_somethings? In the database or filesystem directory?
thanks.
Since it is created by your code, you can only find it once your code runs successfully. Before that, you won't be able to find it anywhere.
So I suggest you correct your code as I mentioned, run it, and then post the whole log here by copy/pasting it into a window opened with this button:
%let lib_mylib=&scan(myLib,1,.);
Is lib_mylib already pointing to an existing library? What does it resolve to?
Run the following and post the log.
%let lib_mylib=&scan(myLib,1,.);
%put My Library = &lib_mylib.; proc datasets lib=&lib_mylib; run;quit;
I suspect you don't have a libname. FYI - this code does nothing at all, it creates an empty data set with a single empty variable.
Let's just ignore the typos in your posted code and concentrate on the question.
When you reference a macro variable you can use a period to let SAS know where the name of the macro variable ends. You don't need the period when the next character in the program cannot be part of a macro variable name, like a space or a slash or parentheses. But when the next character could be part of the name then the period is required. So if you write &MYMVAR_START then it is looking for a variable named MYMVAR_START. If you want it to instead look for MYMVAR then add the dot. &MYMVAR._START.
In your case you want an actual period between the name of the libref and the name of the member. So since first period will be used by the macro processor to know that you are done typing the macro variable name you need the second one so that when SAS sees the generated code there is still a period between the libref and member name.
Sorry, I suspect that we are going out of the topic.
The code that I showed in the above post is only as example and introduction for my questions.
Precisely, my question is:
Physically where I find the persistent dataset named that we create through a code like above?
Is a persistent dataset stored in a file of the filesystems?
Or is it stored in a metadata table like sql table?
So, where I find physically the persistent dataset named start_somethings? In the database or filesystem directory?
thanks.
@vinpres wrote:
Sorry, I suspect that we are going out of the topic.
The code that I showed in the above post is only as example and introduction for my questions.
Precisely, my question is:
Physically where I find the persistent dataset named that we create through a code like above?
Is a persistent dataset stored in a file of the filesystems?
Or is it stored in a metadata table like sql table?
So, where I find physically the persistent dataset named start_somethings? In the database or filesystem directory?
thanks.
It depends.
If your libref is a simple SAS library that is pointing to a physical directory.
libname mylib '/mydirecotry';
Then the dataset referenced by MYLIB.FRED is a physical file name fred.sas7bdat in the physical directory named /mydirectory. Note that the extension used by SAS on the files that are SAS datasets have changed over the years and could change again in the future, but have consistently been sas7bdat for a number of years.
Now if MYLIB is using some other libref engine then you need to check that engine for how it works. If it is Oracle then it is a table in the schema that you pointed the libref to. If it is the XLSX engine the it is a sheet in the workbook that you pointed the libref to.
PS. None of your code or your clarifications of the question have anything to do with the concept of LABEL that you used in the subject line.
Labels are completely different than names. SAS allows you to attach labels to variables or datasets where you can enter longer free text descriptions. The labels attached to a dataset are stored inside the dataset and have nothing to do with either the name of the dataset or the name of the physical file that SAS uses to store the dataset.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.