BookmarkSubscribeRSS Feed
dirkvk
Fluorite | Level 6

Hi all,

 

I want to return the info in the sashelp.vtable/dictionary.tables for a specific dataset.

Works fine but why does one take 11 minutes and the other not even a second?

 

I was expecting some difference but not this much of a difference.

Note though that at this location they defined an enormous amount of libs and datasets at start-up.

 

Just curious for your thoughts on this...

 

 

%macro DSInfo(DSInfo,LibName,DSName);
data &DSInfo;
  set sashelp.vTable (where = (libname = %upcase("&LibName") and memname=upcase("&DSName") ) );
run;
%mend;

%macro DSInfo2(DSInfo,LibName,DSName);
proc sql noprint;
  create table &DSInfo as select * from dictionary.tables where libname = upcase("&LibName") and memname = upcase("&DSName");
quit;
%mend;

%let StartTime = %sysfunc(time());
%DSInfo(DSInfo,WORK,_prodsavail);
%let EndTime = %sysfunc(time());
* Anders komt de LOG-booschap niet als 1 geheel: source even uitschakelen;
options nosource;
%put ***********************************************************************;
%put Programma duur: %sysfunc(putn(%sysevalf(&EndTime-&StartTime),time10.2));
%put ***********************************************************************;
options source;

%let StartTime = %sysfunc(time());
%DSInfo2(DSInfoSQL,WORK,_prodsavail);
%let EndTime = %sysfunc(time());
* Anders komt de LOG-booschap niet als 1 geheel: source even uitschakelen;
options nosource;
%put ***********************************************************************;
%put Programma duur: %sysfunc(putn(%sysevalf(&EndTime-&StartTime),time10.2));
%put ***********************************************************************;
options source;

 

5 REPLIES 5
Kurt_Bremser
Super User

Which SAS version is implemented?

 

I have the impression that SAS has improved the way a where condition in the data step is handed over to the SQL view, because with earlier SAS versions I found that using the view led to a read through all datasets in all libraries before the where condition was applied.

dirkvk
Fluorite | Level 6

Hi Kurt,

 

Thanks 4 your reply. I am on SAS 9.3 at this client. Running in EG 5.1 if that matters.

Kurt_Bremser
Super User

@dirkvk wrote:

Hi Kurt,

 

Thanks 4 your reply. I am on SAS 9.3 at this client. Running in EG 5.1 if that matters.


They should seriously consider upgrading to 9.4M5. I have not experienced a performance penalty with the view in a similar situation:

data class;
set sashelp.class;
run;

data info1;
set sashelp.vtable (where=(libname = upcase("work") and memname= upcase('class')));
run;

That took just a fraction of a second, even though I have lots of libraries with several hundred thousand datasets active.

ballardw
Super User

You didn't indicate which one took longer.

 

I suspect that the SQL version ran quicker as I have seen that occur and I believe that it has to do with the nature of a SAS VIEW, which the sashelp.vtable is and optimizations used with the DICTIONARY equivalent.

 

I note that on my system that the data step approach can create notes such as

NOTE: The map data sets in library MAPSGFK are based on the digital maps from GfK GeoMarketing
      and are covered by their Copyright. For additional information, see
      http://support.sas.com/mapsonline/gfklicense.

that the SQL dictionary table doesn't.

 

 

For giggles you should also try Proc SQl addressing the sashelp.vtable instead of the Dictionary table as another comparison. On my system the time for the data step and Proc Sql using sashelp.vtable are nearly identical though CPU time is slightly less for Proc SQL.

dirkvk
Fluorite | Level 6

Hey, just now I realized that I did not answer here - It was the data step on the view that took 11 minutes, :-), as you suspected.

Thanks all 4 your input!

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 1083 views
  • 0 likes
  • 3 in conversation