BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Patrick
Opal | Level 21

There must be some simple SAS syntax for this ...but just can't figure it out.

I know the full metadata path and name for a metadata object (table). How can I test if this metadata object exists?

1 ACCEPTED SOLUTION

Accepted Solutions
LinusH
Tourmaline | Level 20

Maybe you can try the METADATA_PATHOBJ function. It returns -3 if the object is not found:

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lrmeta/p1xunv8xz32p17n111eqr6edimy1.htm

Data never sleeps

View solution in original post

5 REPLIES 5
LinusH
Tourmaline | Level 20

Maybe you can try the METADATA_PATHOBJ function. It returns -3 if the object is not found:

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lrmeta/p1xunv8xz32p17n111eqr6edimy1.htm

Data never sleeps
Patrick
Opal | Level 21

@LinusH I was a bit too quick to accept your post as solution.

Running below I get an rc of -2 which means "syntax error in path" even though I've copy/pasted the path directly from SMC as well as the table name.

data _null_;
    length id $20;
    length type $256;
    proj="";
    deftype="";
    id="";
    type="";

    rc=metadata_pathobj(proj,"/Folder1/Folder 2/Data/Visual Analytics(CLASS_2)",
                        deftype,type,id);

    put rc=;
    put id=;
    put type=;

run;

Not sure why that's not working given this is in the foundation repository and I'm creating this metadata table object with the same user (so not a permission issue).

....and I actually found very similar code in the template I've used as a starting point of my code. Hmmm....

 

 

Patrick
Opal | Level 21

It worked once I used syntax as per https://support.sas.com/kb/42/872.html 

LinusH
Tourmaline | Level 20
I couldn't find the actual dftypes to use, just seeing som examples, not a complete list or reference in the doc?
Data never sleeps

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 730 views
  • 2 likes
  • 2 in conversation