DATA Step, Macro, Functions and more

Access Table created in SAS

Reply
Occasional Contributor
Posts: 7

Access Table created in SAS

Hi Team,

 

I have created a SAS table by Proc Sql and then tried to create another table from the table created first like teh below example:

 

Proc SQL;

 

CREATE TABLE A AS SELECT * from B;

 

quit;

 

PROC SQL;

 

CREATE TABLE C AS SELECT * from A;

 

quit;

 

When I try executing the second SQL query I am getting error as A not found.

Kindly Help.

PROC Star
Posts: 768

Re: Access Table created in SAS

[ Edited ]

Your code seems to be working on the following simple test data?

 

data B;
input var1 var2;
datalines;
1 2
3 4
5 6
;

Proc SQL;
CREATE TABLE A AS SELECT * from B;
quit;

PROC SQL;
CREATE TABLE C AS SELECT * from A;
quit;

 

See log below

 

 Udklip.PNG

Occasional Contributor
Posts: 7

Re: Access Table created in SAS

It is just an example on what I am working on explained in the below steps.

  1. B is another table existing in database and I am creating a table A selecting data from B.
  2. Then creating another table C selecting data from table A created in the previous step

 

PROC Star
Posts: 768

Re: Access Table created in SAS

Can you provide some sample data or some of the actual code you are using, because nothing is wrong in the code you have posted above Smiley Happy

Occasional Contributor
Posts: 7

Re: Access Table created in SAS

PROC SQL;
Create Table Employee AS SELECT A.NAME,A.SALARY,B.DEPT FROM EMP1 A LEFT JOIN DEPARTMENT B ON A.EMP_ID= B.EMP_ID ;
QUIT;

/***************************************************/
PROC SQL;
CREATE TEMPLE TEMP AS SELECT * FROM EMPLOYEE;

QUIT;

I am getting error 'Employee not found'

Hope this helpsSmiley Happy
Super User
Posts: 7,868

Re: Access Table created in SAS


simrut wrote:
PROC SQL;
Create Table Employee AS SELECT A.NAME,A.SALARY,B.DEPT FROM EMP1 A LEFT JOIN DEPARTMENT B ON A.EMP_ID= B.EMP_ID ;
QUIT;

/***************************************************/
PROC SQL;
CREATE TEMPLE TEMP AS SELECT * FROM EMPLOYEE;

QUIT;

I am getting error 'Employee not found'

Hope this helpsSmiley Happy

Post the log of both of those steps when running them in immediate succession.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 11,343

Re: Access Table created in SAS


simrut wrote:
PROC SQL;
Create Table Employee AS SELECT A.NAME,A.SALARY,B.DEPT FROM EMP1 A LEFT JOIN DEPARTMENT B ON A.EMP_ID= B.EMP_ID ;
QUIT;

/***************************************************/
PROC SQL;
CREATE TEMPLE TEMP AS SELECT * FROM EMPLOYEE;

QUIT;

I am getting error 'Employee not found'

Hope this helpsSmiley Happy

 

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