Desktop productivity for business analysts and programmers

How to use the select statement within proc metalib statement

Accepted Solution Solved
Reply
Contributor ak2
Contributor
Posts: 27
Accepted Solution

How to use the select statement within proc metalib statement

Hi! I want to store a table into a library using proc metalib and the select statement, but my table is not added to the library called myLib. I also need the table to have a macro (&myDate.) as a table name. Can anyone help me with this? This is my code:

 

data myLib.&myDate;

set x;

run;

 

proc metalib;

omr(library="myLib" repname="something");

select (myLib.&myDate);

update_rule=(delete);

run;

 

And the log output:

NOTE: Metadata for 0 tables was updated.

NOTE: Metadata for 0 tables was deleted.

NOTE: Metadata for 0 tables was added.

NOTE: Metadata for 0 tables matched the data sources.

NOTE: 1 tables listed in the SELECT or EXCLUDE statement were not found in either the metadata or the data source.

NOTE: 0 other tables were not processed due to error or UPDATE_RULE.

 

 


Accepted Solutions
Solution
‎03-29-2016 08:50 AM
Esteemed Advisor
Esteemed Advisor
Posts: 7,203

Re: How to use the select statement within proc metalib statement

Well, I don't know this procedure, however I would give you some points:

Why specify library - mLib - in both the cmr() and the select(), surely it should only appear in the cmr.  And according to the documentation:

http://support.sas.com/documentation/cdl/en/lrmeta/60739/HTML/default/viewer.htm#a003181502.htm

It should look like: select("&MyDate.");

You will see this note states the select wasn't found: 

NOTE: 1 tables listed in the SELECT or EXCLUDE statement were not found in either the metadata or the data source.

 

Also note, that macro variables can have spaces at the end to make the length up, so you might need %trim() in there as well, but try the above.  Now, this assumes that in the library mlib, you have a dataset which is the same text as mydate.  However what I would say is that dates - unless you start with a character - are not valid SAS names, so maybe that is your problem, you haven't showed what &Mydate actually resolves to.  

 

As another tip, don't put "data" items in names, its never a good idea.  By "data", I mean things like dates, which should be in datasets (as in the name "data"sets) - names are for programming purposes so make them simple and generic.

 

 

View solution in original post


All Replies
Solution
‎03-29-2016 08:50 AM
Esteemed Advisor
Esteemed Advisor
Posts: 7,203

Re: How to use the select statement within proc metalib statement

Well, I don't know this procedure, however I would give you some points:

Why specify library - mLib - in both the cmr() and the select(), surely it should only appear in the cmr.  And according to the documentation:

http://support.sas.com/documentation/cdl/en/lrmeta/60739/HTML/default/viewer.htm#a003181502.htm

It should look like: select("&MyDate.");

You will see this note states the select wasn't found: 

NOTE: 1 tables listed in the SELECT or EXCLUDE statement were not found in either the metadata or the data source.

 

Also note, that macro variables can have spaces at the end to make the length up, so you might need %trim() in there as well, but try the above.  Now, this assumes that in the library mlib, you have a dataset which is the same text as mydate.  However what I would say is that dates - unless you start with a character - are not valid SAS names, so maybe that is your problem, you haven't showed what &Mydate actually resolves to.  

 

As another tip, don't put "data" items in names, its never a good idea.  By "data", I mean things like dates, which should be in datasets (as in the name "data"sets) - names are for programming purposes so make them simple and generic.

 

 

Contributor ak2
Contributor
Posts: 27

Re: How to use the select statement within proc metalib statement

I changed select (myLib.&myDate) to select ("&myDate") and it seems to be working as expected. Thank you so much for your help!
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 338 views
  • 0 likes
  • 2 in conversation