BookmarkSubscribeRSS Feed
alperebb
Calcite | Level 5

Hello,

We ran a query code in the SAS Develop section and it brought us the values we wanted in the output data section. But we couldn't figure out how to convert the output data table into a new table. I will share two screenshots. In the first one we have our query code. In the other one, I have the output data that I will share by hiding the information. Please help me to convert this output data into a table.

 

Here is the code.

PROC SQL;
    CREATE TABLE WORK.QUERY_FOR_PO_PR_SSH1 AS
        SELECT
            t1.Created_By,
            t1.No_,
            t1.'Posting Description'n,
            t1.'Vendor Invoice No_'n,
            t1.Invoice_,
            t1.'Cancel Reason'n,
            t1.'Cancel Reason Text'n,
            t1.'Modifed By'n,
            t1.'Deleted By'n,
            t1.'Purchase_ Order_Date'n,
            t1.Creation_Date,
            t1.Original_Invoice_Date,
            t1.'Purchase_ Order_Date'n AS 'Purchase_ Order_Date1'n
        FROM
            TEST.PO_PR_SSH1 t1
        WHERE
            t1.'Purchase_ Order_Date_'n < t1.'Original_Invoice_Date_'n
    ;
QUIT;

MicrosoftTeams-image.pngMicrosoftTeams-image (1).png

 

1 REPLY 1
Patrick
Opal | Level 21

Below from the generated code is already creating a table in SAS WORK.

Patrick_0-1679381204666.png

Tables under SAS WORK get physically saved on disk but only exist as long as your SAS session exists (=SAS deletes the physical folder location for WORK and all its content on termination of your SAS session).

 

If you want to store the table permanently then just point it to a different libref (other than WORK) when using the wizard.

The libref must pre-exist - either available via a pre-assigned library or then via a libname statement executed before you use the wizard.

 

You could also just copy/past the generated code into a code node and then modify manually. Somethin like:

libname perm '/mydata/demo/myfolder';
PROC SQL;
    CREATE TABLE perm.mytable AS
        SELECT
        ......
      ;
quit;

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 563 views
  • 0 likes
  • 2 in conversation