Hi Thanks a lot for your reply. I had a look at the Usage Note, then Googled "%metaauto", which led me to this useful SGF paper: http://support.sas.com/resources/papers/proceedings11/309-2011.pdf. I had a look at the %metaauto macro (C:\Program Files\SASHome\SASFoundation\9.3\core\sasmacro\metaauto.sas on my machine), as well as all the internal macros, esp. metadata_getDatafileFromPath. However, this begs a few questions: 1) Why the difference between the generated metadata item path between a DATASOURCE and DATASOURCEITEM prompt??? (Note: my datasource prompt is named DATASOURCE; my datasourceitem prompt is named COLUMN). A DATASOURCE prompt generates macro variables like: DATASOURCE=/Shared Data/CLASS(Table) DATASOURCE_TYPE=1 while a DATASOURCEITEM prompt generates macro variables like: COLUMN1=Name COLUMN_COUNT=5 COLUMN_PATH1=/Shared Data/CLASS COLUMN_SOURCE_TYPE1=1 (a Table) COLUMN_TYPE1=1 (a Char variable) I'm guessing (pure conjecture) that (Table) is part of the metadata item path? After all, I could have metadata objects CLASS(Table), CLASS(Cube), CLASS(Infomap), CLASS(OLAP Infomap) all stored in /Shared Data. I'm assuming that (Table) is a bit analogous to a file extension, and that /Path/ObjectName(ObjectType) forms a complete path? Regardless of whether this is technically accurate, in reviewing the code for metadata_getDatafileFromPath: rc = metadata_pathobj('', "&PATH", '', pathtype, pathid); only works for /Shared Data/Class(Table), NOT /Shared Data/Class. But, if COLUMN_PATH1=/Shared Data/CLASS is meant to be "the path to the metadata item object from which the datasourceitem is derived", then why specify an incomplete (as your macro states a "malformed") path??? 2) Ok, that's likely someone else's code with the design bug. But, if TYPE= is a required parameter to your macro, then why don't you work around this design bug in the prompt manager code? I would think something like this would work: %macro test(path=, type=); %* Strip leading and trailing spaces ; %let path=%sysfunc(strip(&path)); %* Folders can contain parentheses, so use defensive programming ; %* Assume "#" is not in the path, otherwise use some other delimiter ; %let rx=%sysfunc(prxparse(#^(.*)(\(Table\)|\(Cube\)|\(InfoMap\))$#)); %if %sysfunc(prxmatch(&rx,&path)) %then %let path=%sysfunc(prxposn(&rx,1,&path)); %syscall prxfree(rx); %if (&type eq 1) %then %let path=&path(Table); %else %if (&type eq 2) %then %let path=&path(Cube); %else %if (&type eq 4) %then %let path=&path(InfoMap); %put &=path; %mend; %test(path=/Shared Data/Class(Table), type=1); %test(path=/Shared Data/Class(Cube), type=2); %test(path=/Shared Data/Class(InfoMap), type=4); %test(path=/Shared Data/Class(Cube), type=1); * note mismatch on (type) and type= ; %test(path=/Shared Data/Class, type=1); %test(path=/Shared Data/Class, type=2); %test(path=/Shared Data/Class, type=4); %test(path=/Funky/(Path) (With) (Table)/Class,type=1); * yes, I created this folder using SMC! ; (We don't use OLAP or Information Maps, so I'm just guessing re: the (object type ) specification - edit as required) 3) If code similar to the above was in the %metadata_getDatafileFromPath macro, then it would also work with DATASOURCEITEM prompts (although it would be better if the prompt manager design bug was fixed so you didn't have to). Here is an example where I "wrap" your macro: %macro my_metadata_getDatafileFromPath( path=, type=, outvar=, assignlib=N, showver=N, debug= ); %* Strip leading and trailing spaces ; %let path=%sysfunc(strip(&path)); %* Folders can contain parentheses, so use defensive programming ; %* Assume "#" is not in the path, otherwise use some other delimiter ; %let rx=%sysfunc(prxparse(#^(.*)(\(Table\)|\(Cube\)|\(InfoMap\))$#)); %if %sysfunc(prxmatch(&rx,&path)) %then %let path=%sysfunc(prxposn(&rx,1,&path)); %syscall prxfree(rx); %if (&type eq 1) %then %let path=&path(Table); %else %if (&type eq 2) %then %let path=&path(Cube); %else %if (&type eq 4) %then %let path=&path(InfoMap); %metadata_getDatafileFromPath( path=&path, type=&type, outvar=&outvar, assignlib=&assignlib, showver=&showver, debug=&debug ); %mend; %macro loop; %do i=1 %to &column_count; %my_metadata_getDatafileFromPath( path=&&COLUMN_PATH&i, type=&&COLUMN_SOURCE_TYPE&i, assignlib=n, outvar=COLUMN_TABLE&i, debug= ); %put COLUMN_TABLE&i=&&column_table&i; %end; %mend; %loop; 4) Minor: if debug=y means "debug", then debug=n should mean "don't debug". IMO debug=<any non blank value> meaning "don't debug" is confusing, and I have to troll through the macro code to work it out. I was a bit worried about the performance impact of having to call the macro, but it's really fast. Your macro goes a long way to helping me solve my programming issue. I still wish: 1) the source libname.dataset name were part of the macro variables created by the prompt manager, 2) I could hide the unwanted information from the datasource and datasourceitem user-interface components, and 3) I could create dynamic prompting, setting a dependency on datasourceitem on the upstream datasource selection. I suspect this isn't even your code, but perhaps you could pass my opinions to the appropriate persons... Regards, Scott
... View more