SAS PROCs - San Francisco State University

SAS PROCs ISYS 650 PROC Statement Syntax PROC name options; Statements statement options; RUN; Procedure Options DATA = N = Number of subjects is: Include the number of observations in the output

Proc Print data=Mydata.Employee N; run; PROC Statements VAR variables; To use only the variables in the list for analysis. BY variables; Cause SAS to repeat the procedure for value of the

variables, similar to GROUP BY. SUM variables Include total for specified variables TITLE Examples Proc MEANS data=Mydata.Emp; VAR Salary; BY Race; run;

PROC PRINT data=Mydata.Emp N; VAR Name Sex Race Salary; SUM Salary; TITLE 'Employee List'; run; PROC SORT data=Mydata.Emp; BY Name; run; PROC PRINT; VAR Name Race Salary; RUN;

PROC SQL PROC SQL is a powerful Base SAS Procedure that combines the functionality of DATA and PROC steps into a single step. PROC SQL can sort, summarize, subset, join (merge), and concatenate datasets, create new variables, and print the results or create a new table or view all in one step! PROC SQL can be used to retrieve, update, and report on information from SAS data sets or other database products. Creating a SAS Data Set Using ODBC and

SQL Create Table Command Permanent data set: PROC SQL; CONNECT TO ODBC(DSN='MySalesDB2007'); CREATE TABLE MyData.Customers AS SELECT * FROM CONNECTION TO ODBC(SELECT * FROM Customer); Quit; **Note: End with the Quit command. Temporary data set: PROC SQL; CONNECT TO ODBC(DSN='MySalesDB2007'); CREATE TABLE Customers AS SELECT * FROM CONNECTION TO ODBC(SELECT * FROM Customer);

Quit; PROC PRINT; RUN; Creating Data Set as a Result of a Join Command PROC SQL; CONNECT TO ODBC(DSN='MySalesDB2007'); CREATE TABLE temp_sas AS SELECT * FROM CONNECTION TO ODBC(SELECT Customer.CID, Cname, OID, Odate FROM Customer, Orders where Customer.cid=orders.cid); Quit; Proc Print;

Run; Creating a View PROC SQL; CREATE VIEW ACustomer AS SELECT * FROM MyData.Customers where Rating='A'; Quit; Proc Print Data=ACustomer; Run; Select Records from a SAS Data Set PROC SQL;

SELECT * FROM MyData.Customers Where Rating='A'; Quit; PROC SQL; SELECT City, Count(CID) AS NumberOfCustomer FROM MyData.Customers Group By City; Quit; PROC SQL; SELECT City, Count(CID) AS NumberOfCustomer FROM MyData.Customers Group By City Having Count(CID)>5; Quit;

Run SQL DML Command Delete: PROC SQL; DELETE * FROM MyData.Emp Where name is Null; Quit; Update: PROC SQL; UPDATE MyData.Customers Set Rating='A' Where CID='C01'; Quit;

Insert: PROC SQL; INSERT INTO MyData.Customers Values('C49','Smith','SF','C'); Quit; ODBC Connection to Oracle: User and Password PROC SQL; CONNECT TO ODBC(DSN='OracleDChao' user='dchao' password='dchao'); CREATE TABLE CatSalesPlan AS SELECT * FROM CONNECTION TO ODBC(SELECT * FROM SalesPlan); Quit;

Join a total sales query from a data warehouse with a management plan in Oracle PROC SQL; CONNECT TO ODBC(DSN='DWNW'); CREATE TABLE CatSales AS SELECT * FROM CONNECTION TO ODBC(SELECT * FROM SalesByCatYear where year=1998); Quit; PROC SQL; CONNECT TO ODBC(DSN='OracleDChao' user='dchao' password='dchao'); CREATE TABLE CatSalesPlan AS SELECT * FROM CONNECTION TO ODBC(SELECT * FROM SalesPlan);

Quit; Proc SQL; Select C.categoryID, C.Year,ActualSales, ProjectedSales, ActualSales/ProjectedSales*100 as PercentSales from CatSales C, CatSalesPlan p where C.CategoryID=p.CategoryID and C.Year=p.Year; Quit; Output Delivery System, ODS With ODS you can choose to create output in other formats, including HTML, RTF and PDF. ODS HTML; Proc print data=StGpa ;

run; ODS HTML CLose; ODS PDF file='C:\MyData\PDFCustomer.PDF'; Proc print data=Mydata.Customers ; run; ODS PDF CLose; ODS RTF file='C:\MyData\RTFCustomer.RTF'; Proc print data=Mydata.Customers ; run; ODS RTF CLose;

Recently Viewed Presentations

  • Information Systems Manage

    Information Systems Manage

    Information Systems Management (ISM) at UC Santa Cruz Subhas Desa What is Information Systems Management (ISM)? The Technology of Business: the design and use of technologies to efficiently and profitably manage and operate any enterprise or company The Business of...
  • Implementing Neural Networks for Text Classification: Data Sets

    Implementing Neural Networks for Text Classification: Data Sets

    Times New Roman Arial Courier New Fireball Implementing Neural Networks for Text Classification: Data Sets Data Set Selection Advantages of Standard Data Sets Most popular corpora Reuters-21578 data set Reuters-21578 data set Example of a Reuter-21578 document 20-newsgroup data set...
  • Federalism - longovt.com

    Federalism - longovt.com

    Explanation for federalism "…it clearly appears, that the same advantage which a republic has over a democracy, in controlling the effects of faction, is enjoyed by a large over a small republic-is enjoyed by the Union over the States composing...
  • K-Award Workshop: Mentorship Plan - ICTS Iowa

    K-Award Workshop: Mentorship Plan - ICTS Iowa

    K-Award Workshop: Mentorship Plan. Peg Nopoulos, M.D. Professor of Psychiatry, Pediatrics and Neurology. Your Primary Mentor. It all starts here. You need a Rock Start Mentor. Well funded lab by the NIH. Provides resources.
  • PPT Votre Europe votre avis 2017 - European Economic and ...

    PPT Votre Europe votre avis 2017 - European Economic and ...

    La mondialisation rend-elle l'UE plus ou moins importante? Questions pouvant être posées Méthodes de travail Vous travaillerez en équipe. Les principales conclusions des groupes de travail seront ensuite communiquées lors de la session plénière finale de Votre Europe, votre avis...
  • Poll Question - Senturus

    Poll Question - Senturus

    Author: devo Created Date: 05/22/2015 03:21:32 Title: Poll Question Last modified by: Bobbi Ewelt
  • The Ideal Gas Law and Kinetic Theory - Mrs. Haug's Website

    The Ideal Gas Law and Kinetic Theory - Mrs. Haug's Website

    Trebuchet MS Arial Wingdings 2 Wingdings Calibri Opulent 1_Opulent 2_Opulent 3_Opulent 4_Opulent Microsoft Equation 3.0 The Ideal Gas Law and Kinetic Theory 14.1 Molecular Mass, The Mole, and Avogadro's Number 14.2 The ideal Gas Law More ideal Gas law Review...
  • Introduction to Oracle Application Express

    Introduction to Oracle Application Express

    Introduction to Application Express (formerly HTML DB) * * Reference Materials * Referencing Items Substitution String #variableName# Short Substitution String &variableName PL/SQL v('variableName') nv('numericValue') Bind Variable :variableName Items can be used to: Include a substitution string within a template Create...