SAS Language - Components

Components

SAS Language has separate sub components called the Output Delivery System (ODS), SAS Macro Language, and SAS SQL steps.

ODS system

It can output files to a variety of formats notably Excel, Rich Text (Word) and PDF.

An example of ODS code is

ODS HTML File =" Path of file storage /File Name .Extension"; Proc Step 1, Proc Step 2.... for output ODS HTML Close;

Here Extension will be .xls (For Microsoft Excel files, .pdf for Adobe Acrobat files,.doc for Microsoft Word files,.RTF for rich text format files)

The SAS Macro language is used for repeatable steps.

Its format is explained as below

start of a macro with %MACRO namemacro(variables,...); variable with a suffix of "%" within the Macro, end of a macro with %MEND ; Calling Macro with %Namemacro(value of variable1 in N th run, value of variable2 in N th run,...);

A illustrative example of SAS Macro Language is below.

Note in SAS language comments begin with a /* and end with */

/*PROGRAM TO AUTOMATE REPORTING*/ /*DECLARING THE PATH OF THE INPUT/OUTPUT FOLDER*/ %let pathfile = ‘X:\Auto\AUG06-AUTOS\’ ; /*CREATING LIBRARY NAME*/ libname auto &pathfile; run; /*TO CONSERVE SPACE*/ options compress=yes; /*TO MAKE LOG READABLE*/ options macrogen symbolgen; /*STARTING MACRO FOR REPEATABLE EXECUTION OF REPORT*/ %macro impmth(mth,num,emailid); /*MANIPULATING VARIABLES TO REDUCE CHANGES*/ data _null_ ; call symput(’filepath’,”‘”||&pathfile||&mth||’.csv’||”‘” ); call symput(’unqpath’,”‘”||&pathfile||”unq”||&mth||’.csv’||”‘” ); call symput(’unqxls’,”‘”||&pathfile||”unq”||&mth||’.xls’||”‘” ); run; /*IMPORT*/ /*IMPORTING DATA FROM CSV FILES STORED IN FOLDER DECLARED ABOVE*/ PROC IMPORT OUT= auto.&num DATAFILE= &filepath DBMS=CSV REPLACE; GETNAMES=YES; DATAROW=2; quit; /*CREATING VARIABLE FOR DISTINGUISHING INPUT*/ data auto.# set auto.# &num =1; run; ———————————————————————– /*PROCEDURE HERE REMOVING DUPLICATES*/ proc sort data=auto.&num nodupkey; by REFAGREEMENTID; run; ———————————————————————– /*EXPORT*/ /*EXPORTING DATA TO A CSV FILE*/ PROC EXPORT DATA= AUTO.&num OUTFILE= &unqpath DBMS=CSV REPLACE; RUN; /*EXPORTING DATA TO A XLS FILE*/ ODS HTML FILE=&unqxls; proc print data=auto.# run; ODS HTML CLOSE; /*EMAILING THE RESULTS*/ filename outbox email &emailid; data _null_ ; file outbox to=(&emailid)/*Overrides value in filename statement*/ cc=(&emailid) subject=’File from’ attach=(&unqxls) ; put ‘Hi,’; put ‘This is an integrated approach to automating reports’; put ‘It works great!’; run; %mend; /*INVOKING THE MACRO*/ /*HERE ‘Ahmedabad’ IS THE INPUT FILE WHILE Ahd IS THE OUTPUT FILE*/ /*HERE ‘good@sas.com’ IS THE EMAIL ID TO BE MAILED THE REPORT*/ %impmth(’Ahmedabad’,Ahd,’good@sas.com’);

The SAS SQL steps are simple combinations of Structured Query Language, SQL with a prefix of "PROC SQL".

SAS User Groups are User Groups of SAS Language, some of them with and some of them without active financial support of SAS Institute.

This includes the http://www.sascommunity.org, http://www.basas.com,http://www.labsug.org,http://www.views-uk.demon.co.uk and http://www.philasug.org .

The SAS -L user group list is the biggest e-group for SAS Language Users for technical help.

The SAS compiler includes modules originally written in machine language as well as PL/1 (see SAS System) and rewritten much more recently in C/C++. Java appears to have a role as well in very recent extensions such as hash objects. The SAS Data step is a Turing-complete programming language in that it supports assignments, alternations, and iterations (the control elements of all procedural programming languages). SAS PROC SQL extends SAS to a set-logic language. So SAS can be considered a general programming language, though it serves largely as database programming language and a language with a wide variety of specialized analytic and graphic procedures. Within the last decade or so, the SAS System has increasingly become a generic platform for elaborate products such as SAS/EM, SAS/Intrnet, and SAS/Access engines.

Attributed-SAS Archives Discussion

Read more about this topic:  SAS Language

Famous quotes containing the word components:

    Hence, a generative grammar must be a system of rules that can iterate to generate an indefinitely large number of structures. This system of rules can be analyzed into the three major components of a generative grammar: the syntactic, phonological, and semantic components.
    Noam Chomsky (b. 1928)