Sharing proc sql tables across SAS programs

Reply
New Contributor
Posts: 3

Sharing proc sql tables across SAS programs

I'm a SAS newbie. In the first SAS program I create table mytable as ... in the second SAS program I try to select * from my table ... I get ERROR: File WORK.MYTABLE.DATA does not exist.  I've just spent about three hours googling - no joy

Super Contributor
Posts: 349

Re: Sharing proc sql tables across SAS programs

Hi,

Try this..

proc sql;

create table mytable as

select * from sashelp.class;

quit;

proc sql;

select * from mytable;

quit;

Thanks,

Shiva

New Contributor
Posts: 3

Re: Sharing proc sql tables across SAS programs

Thanks for the quick reponse,  That's exactly what I'm doing, except they're in two seperate SAS programs.  The first does the create table, then the second does the select from mytable.


BTW:  How do I paste into this editor?

Super Contributor
Posts: 349

Re: Sharing proc sql tables across SAS programs

Hi,

You can call your first program using %include.

%inc 'F:\Test\first.sas';

proc sql;

select * from mytable;

quit;

Thanks,

Shiva

Super User
Posts: 11,343

Re: Sharing proc sql tables across SAS programs

When you say "two separate SAS programs" are they running in the same session? If not your WORK library by default is cleaned up by SAS at the end of the session and all data sets are deleted. Nehcour0420 suggestion below is how to create data sets that persist between sessions.

Since you say your are a new user the concept of LIBRARY is an important one to working in SAS.

Contributor
Posts: 25

Re: Sharing proc sql tables across SAS programs

Try to assign a library to your table, using:

Libname library_name  '/sas/sasdata/library_name';

Then create table using:

create table library_name.mytable as

New Contributor
Posts: 3

Re: Sharing proc sql tables across SAS programs

Posted in reply to Nehcour0420

Many thanks, just what I needed.

Ask a Question
Discussion stats
  • 6 replies
  • 333 views
  • 0 likes
  • 4 in conversation