Topics Map > SAS
Using SAS Enterprise Guide
Querying Databases
-
If you have not already, configure and run your connections; see Configuring Connections in SAS Enterprise Guide.
-
In the process flow work area, click Tasks > Browse.
-
Navigate to Data > Query Builder. You can also search for Query Builder in the search box. To favorite the task, click the star icon. Click Query Builder and click Open.
-
Click Servers in the left pane and navigate to Local > Libraries. You should see the various databases specified in your connections file.
-
Navigate into the database you want to query and find the table you want. Click Open.
-
You can now put together the various parts of querying the database table. You can drag and drop column names into any of the tabs. To join tables, click Join Tables and navigate to the table you want to join. SAS will automatically download tables as needed for heterogeneous joins (see https://documentation.sas.com/?activeCdc=egdoccdc&cdcId=egcdc&cdcVersion=8.3&docsetId=egug&docsetTarget=n18a187foaek0qn1ntln5smn6d7m.htm&locale=en ).
Importing Local Data
-
In the process flow work area, click Tasks > Browse.
-
Navigate to Data > Import Data. You can also search for Import Data in the search box. To favorite the task, click the star icon. Click Import Data and click Open.
-
Follow the prompts to locate the file on your local computer.
-
Step through the Import Data wizard and confirm / change details, as necessary.
Exporting Data
-
In the process flow work area, right click the table you want to export and click Share > Export.
-
Enter a file name and location and change file types as necessary.
Alternatively, you can configure exporting data as part of the workflow by clicking Export as a step in project and following the wizard.
Viewing and Modifying the SQL Query
-
Follow the steps lisetd above in Querying Databases.
-
Once you have the query in the process flow work area, right-click the Query Builder object and click Extract Code.
-
A new tab will open with the query in a PROC SQL tag. You are now able to copy and modify the query as needed. Note that the query references to tables are relative to the SAS WORK schema and you will likely need to modify database names as needed.
Modifications to the query will NOT change the Query Builder object and modifications to the Query Builder object will NOT change this copy of the code.
Running Native SQL Queries
Download and open NativeQuery.sas for an example of running a subquery on the database.