<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to find which data sets getting updated daily when you connect to database using SAS libname in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-which-data-sets-getting-updated-daily-when-you/m-p/623697#M183658</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/139130"&gt;@buddha_d&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The mentioned code applies to SAS data sets (sashelp.vtable).&amp;nbsp; The tables are getting created in sql server and I am just accessing them using SAS. So I am trying to see how I can check which tables are updated daily. Thanks Ballard for great suggestion.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That means you should talk to your SQL Server admin. There should be a similar table or view to access in the SQL Server DB, though it may be better to use passthrough code to access the server reporting tools than to bring all the table properties into SAS.&lt;/P&gt;</description>
    <pubDate>Mon, 10 Feb 2020 20:52:50 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-02-10T20:52:50Z</dc:date>
    <item>
      <title>How to find which data sets getting updated daily when you connect to database using SAS libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-which-data-sets-getting-updated-daily-when-you/m-p/623679#M183649</link>
      <description>&lt;P&gt;I am using a libname statement to login to database to access tables using SAS. There are over 2000 tables. I am not sure which tables to use. I want to know which tables are getting updated regularly. Is there a way to check that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the strategy I am applying. I am getting all tables information using proc contents and pulling tables that contain any date field (like name like '%DATE%';). Once those tables get pulled then I am looking for those fields that contain date in their names, then pull minimum date as well as maximum date for that specific table. Is there a better way to write macro obtain the results. There are tables which contain 10-15 date fields and I don't know how to code that to fit in macro. Could some one please help me with that. I have the following code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options symbolgen mprint mlogic;

LIBNAME ONE SQLSVR DSN=CUSTOMER_DATAMART SCHEMA=DBO;

proc contents data= one._all_ out=new_one noprint;
run;

PROC SQL;
	CREATE TABLE TIMES AS 
	SELECT DISTINCT MEMNAME,NAME 
	FROM NEW_ONE
		WHERE UPCASE(NAME) LIKE '%DATE%';
QUIT;

PROC SQL;
	CREATE TABLE DS AS 
	SELECT DISTINCT MEMNAME
	FROM TIMES 
		WHERE UPCASE(MEMNAME) LIKE '%DATASETNAME%';
QUIT;

data _null_;
	set ds end=eof;
	call sumputx('dsn'||strip(put(_n_,5.)),memname);
	if eof then do;
	call symputx('n', strip(put(_n_,5.)));
	end;
run;

%macro check;
%DO I=1 %TO &amp;amp;N;
	PROC SQL NOPRINT;
		CREATE TABLE &amp;amp;&amp;amp;DSN&amp;amp;I (COMPRESS=YES) AS 
		SELECT MIN(DATE) AS MIN_DATE, MAX(DATE) AS MAX_DATE
		FROM ONE.&amp;amp;&amp;amp;DSN&amp;amp;I;
	QUIT;
%END;
%MEND;
%CHECK;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2020 20:15:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-which-data-sets-getting-updated-daily-when-you/m-p/623679#M183649</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2020-02-10T20:15:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to find which data sets getting updated daily when you connect to database using SAS libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-which-data-sets-getting-updated-daily-when-you/m-p/623685#M183651</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/139130"&gt;@buddha_d&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am using a libname statement to login to database to access tables using SAS. There are over 2000 tables. I am not sure which tables to use. I want to know which tables are getting updated regularly. Is there a way to check that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Does your company not have any documentation on this? I feel like an email to the DB owners would get you this information more accurately than scanning the data.&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2020 20:24:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-which-data-sets-getting-updated-daily-when-you/m-p/623685#M183651</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-02-10T20:24:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to find which data sets getting updated daily when you connect to database using SAS libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-which-data-sets-getting-updated-daily-when-you/m-p/623688#M183653</link>
      <description>&lt;P&gt;You may want to define exactly what "getting updated regularly" means.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to know about the data&amp;nbsp;set properties then you might want to look at SASHELP.VTABLE, or the Proc Sql equivalent Dictionary.tables.&lt;/P&gt;
&lt;P&gt;One of the variables is CRDATE for creation datetime and another is MODATE for the last datetime it was modified .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For instance if I want to find all of the data sets&amp;nbsp;created on or after a given day such as 09FEB2020:&lt;/P&gt;
&lt;PRE&gt;Proc print data=sashelp.vtable;
   where datepart(crdate) ge '09FEB2020'd and memtype='DATA';
run;&lt;/PRE&gt;
&lt;P&gt;That source has pretty much all of the data set level information that Proc Contents would contain.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2020 20:30:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-which-data-sets-getting-updated-daily-when-you/m-p/623688#M183653</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-02-10T20:30:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to find which data sets getting updated daily when you connect to database using SAS libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-which-data-sets-getting-updated-daily-when-you/m-p/623692#M183656</link>
      <description>&lt;P&gt;The mentioned code applies to SAS data sets (sashelp.vtable).&amp;nbsp; The tables are getting created in sql server and I am just accessing them using SAS. So I am trying to see how I can check which tables are updated daily. Thanks Ballard for great suggestion.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2020 20:45:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-which-data-sets-getting-updated-daily-when-you/m-p/623692#M183656</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2020-02-10T20:45:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to find which data sets getting updated daily when you connect to database using SAS libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-which-data-sets-getting-updated-daily-when-you/m-p/623693#M183657</link>
      <description>&lt;P&gt;Thanks Reeza. I would see who could help me. But, is there a way to code each dataset (memname) along with field name (name) to code to see what datasets get updated daily.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2020 20:47:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-which-data-sets-getting-updated-daily-when-you/m-p/623693#M183657</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2020-02-10T20:47:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to find which data sets getting updated daily when you connect to database using SAS libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-which-data-sets-getting-updated-daily-when-you/m-p/623697#M183658</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/139130"&gt;@buddha_d&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The mentioned code applies to SAS data sets (sashelp.vtable).&amp;nbsp; The tables are getting created in sql server and I am just accessing them using SAS. So I am trying to see how I can check which tables are updated daily. Thanks Ballard for great suggestion.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That means you should talk to your SQL Server admin. There should be a similar table or view to access in the SQL Server DB, though it may be better to use passthrough code to access the server reporting tools than to bring all the table properties into SAS.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2020 20:52:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-which-data-sets-getting-updated-daily-when-you/m-p/623697#M183658</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-02-10T20:52:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to find which data sets getting updated daily when you connect to database using SAS libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-which-data-sets-getting-updated-daily-when-you/m-p/623702#M183659</link>
      <description>&lt;P&gt;Most DBs have a dictionary table type function, you just need to find the right table names.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/139130"&gt;@buddha_d&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks Reeza. I would see who could help me. But, is there a way to code each dataset (memname) along with field name (name) to code to see what datasets get updated daily.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2020 21:16:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-which-data-sets-getting-updated-daily-when-you/m-p/623702#M183659</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-02-10T21:16:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to find which data sets getting updated daily when you connect to database using SAS libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-which-data-sets-getting-updated-daily-when-you/m-p/623709#M183661</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/139130"&gt;@buddha_d&lt;/a&gt;&amp;nbsp;- It is unlikely that PROC CONTENTS will tell you anything useful about when database tables get updated. I ran a quick test against an SQL Server table and the Date Created and Last Modified columns are blank. Please note these columns are more useful for SAS datasets that are typically re-created from scratch each time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With database tables rows get inserted, deleted and modified and often there is a timestamp on each row indicating the time it was loaded. Database dictionary tables will likely provide further useful data.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2020 21:43:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-which-data-sets-getting-updated-daily-when-you/m-p/623709#M183661</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2020-02-10T21:43:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to find which data sets getting updated daily when you connect to database using SAS libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-which-data-sets-getting-updated-daily-when-you/m-p/623732#M183674</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/139130"&gt;@buddha_d&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The mentioned code applies to SAS data sets (sashelp.vtable).&amp;nbsp; The tables are getting created in sql server and I am just accessing them using SAS. So I am trying to see how I can check which tables are updated daily. Thanks Ballard for great suggestion.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're allowed to query&amp;nbsp;&lt;EM&gt;sys.dm_db_index_usage_stats&lt;/EM&gt; then something like below might return what you're after (code not tested).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;LIBNAME ONE SQLSVR DSN=CUSTOMER_DATAMART SCHEMA=DBO;

proc sql;
  connect using one;

  select * 
  from connection to one 
    (
      SELECT OBJECT_NAME(OBJECT_ID) AS DatabaseName, 
          last_user_update, *
      FROM sys.dm_db_index_usage_stats
      WHERE database_id = DB_ID( 'DBO')
    );

  disconnect from one;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Feb 2020 01:37:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-which-data-sets-getting-updated-daily-when-you/m-p/623732#M183674</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-02-11T01:37:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to find which data sets getting updated daily when you connect to database using SAS libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-which-data-sets-getting-updated-daily-when-you/m-p/624078#M183772</link>
      <description>&lt;P&gt;Thanks Patrik for the code. I tested it and I don't have access to&amp;nbsp;sys.dm_db_index_usage_stats . I would look for DBAs to help me.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks all for your suggestions.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2020 04:05:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-which-data-sets-getting-updated-daily-when-you/m-p/624078#M183772</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2020-02-12T04:05:41Z</dc:date>
    </item>
  </channel>
</rss>

