SQL basic syntax in SAS

Source: Internet
Author: User

SQL procedures in SAS can organize data, data merging, and data selection functions.

SQL procedures can stitch two datasets, create tables, delete rows and columns in a table, and simply calculate individual variable values.

For example:

Proc SQL;
CREATE VIEW Work.body AS//select the variable id,de,age,sex from the ad table and add a variable height and a new table body
Select id, DE, age,sex,id**2\age as height//
From Work.ad//You can also merge two tables here, plus two tables from the back
where sex= ' Male ' id>20; Pick the male and id>20 data from the table variable sex

Order by ID;//Sort ID

Proc Print data=body; Print data body named body
Title ' Body ';
Run

That body is the newly created table

1.2 Features of the SQL process step

SQL procedure step does not need to repeat each query, each statement is processed separately, does not need print process step to print out the results of the query, do not use the sort process step to sort, do not need to run, to quit to end the SQL procedure step

1.3 SQL Procedure Step statement

SELECT: Querying data in a data table

ALTER: Add, delete, or modify columns of a data table

Create: Creating a data table

Delete: Remove columns from a data table

DESCRIBE: List The properties of a data table

Drop: Delete a data table, view, or index

Insert: Inserting data into a data table

RESET: No use, no idea what it means.

Select: Choose columns for printing

UPDATE: Modify the value of a column for an existing dataset

2 SQL basic Query function

2.1 SELECT statement Basic Syntax Introduction

SELECT <DISTINCT> Object-item <, ...object-item>

From From-list

<where sql-expression>

<group by Group-by-item <, ... group-by-item>>

<order by Order-by-item <, ... order-by-item>>;

Here Select: Specifies the selected column

From: Specifies the name of the table being queried

WHERE: Conditions for a child dataset

GROUP BY: Classify datasets by group

Having: A subset of data from a group by variable

ORDER BY: Sort the data set

SQL basic syntax in SAS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.