Desktop productivity for business analysts and programmers

Record all datasets created in a session

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 7
Accepted Solution

Record all datasets created in a session

Hi everyone,

 

Does anyone know if it is possible to list all datasets/views which are created in a SAS EG session?

Ideally, the solution would work with notes turned off. 

 

For example, if I called the following macro with a %include:

 

%macro create_dsets;

    options nonotes;

    data testa.dset1;

        a=1;

    run;

    data testb.dset2;

        b=1;

    run;

%mend;

%create_dsets;

 

Can I then recall the datasets created in the session i.e. testa.dset1 testb.dset2?

 

Cheers,

Jordan

 


Accepted Solutions
Solution
3 weeks ago
Super User
Posts: 23,247

Re: Record all datasets created in a session

Posted in reply to jordanw1993

You can look at PROC SCAPROC to trace your programs out while you run them. The results aren't exactly what you want, but could be parsed to be what you want.

 


@jordanw1993 wrote:

Hi everyone,

 

Does anyone know if it is possible to list all datasets/views which are created in a SAS EG session?

Ideally, the solution would work with notes turned off. 

 

For example, if I called the following macro with a %include:

 

%macro create_dsets;

    options nonotes;

    data testa.dset1;

        a=1;

    run;

    data testb.dset2;

        b=1;

    run;

%mend;

%create_dsets;

 

Can I then recall the datasets created in the session i.e. testa.dset1 testb.dset2?

 

Cheers,

Jordan

 


 

View solution in original post


All Replies
Solution
3 weeks ago
Super User
Posts: 23,247

Re: Record all datasets created in a session

Posted in reply to jordanw1993

You can look at PROC SCAPROC to trace your programs out while you run them. The results aren't exactly what you want, but could be parsed to be what you want.

 


@jordanw1993 wrote:

Hi everyone,

 

Does anyone know if it is possible to list all datasets/views which are created in a SAS EG session?

Ideally, the solution would work with notes turned off. 

 

For example, if I called the following macro with a %include:

 

%macro create_dsets;

    options nonotes;

    data testa.dset1;

        a=1;

    run;

    data testb.dset2;

        b=1;

    run;

%mend;

%create_dsets;

 

Can I then recall the datasets created in the session i.e. testa.dset1 testb.dset2?

 

Cheers,

Jordan

 


 

Occasional Contributor
Posts: 7

Re: Record all datasets created in a session

Thanks for that, it's a great starting off point!
Valued Guide
Posts: 559

Re: Record all datasets created in a session

Posted in reply to jordanw1993

Did you try querying the dictionary tables (SASHELP.VTABLE or Dictionary.tables), this table has create date and modified date for the tables which might help you identify the tables created in your active session. SYSDATE and SYSTIME auto macros gives you when your system started. 

Thanks,
Suryakiran
Respected Advisor
Posts: 4,668

Re: Record all datasets created in a session

Posted in reply to SuryaKiran

@SuryaKiran

I like your thinking but I believe your approach won't work anymore in cases where libraries get assigned and also de-assigned in code, where tables get created in a database, or where other people/jobs could write tables to a permanent library at the same time.

Super User
Posts: 10,686

Re: Record all datasets created in a session

Posted in reply to jordanw1993

Use PROC PRINTTO; save LOG and parse it to get tables ?

Respected Advisor
Posts: 4,668

Re: Record all datasets created in a session

@Ksharp

I'd use Proc Scaproc as @Reeza suggests as this will already do quite a bit of log parsing for you.

☑ This topic is solved.

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

Discussion stats
  • 6 replies
  • 342 views
  • 6 likes
  • 5 in conversation