SAS language
Encyclopedia
The SAS language is a data processing and statistical analysis language.

See more on origins of SAS language at SAS System
SAS System
SAS is an integrated system of software products provided by SAS Institute Inc. that enables programmers to perform:* retrieval, management, and mining* report writing and graphics* statistical analysis...

 and at Barr Systems website.

Structure

The SAS language basically divides data processing and analysis into two kinds of steps.

1) Data Steps - Which manipulate data input and creation or deletion of variables .

2) Procedure Steps - Which manipulate analysis and output.The short form for each procedure step is Proc

Each line of code in SAS language ends with a ";"

Data Storage Hierarchy

Data is stored in this hierarchy -

1)Libraries - Which contain datasets.

Libname Good "C:/Data/";

This creates a reference path to library named Good at storage location "C:/Data/";

2)Datasets -Which contain variables and records. Records are rows , and variables are column headers.

Datasets can be temporary (they close when you shut down the SAS Compiling software) or they can be stored to the Operating Disk File System.

data good.dataset1; (Output Dataset Name)
set dataset2; (Input Dataset Name)
run; (Command after each Data step)

This stores the temporary dataset named "Dataset2" into a permanent location "C:/Data/dataset1.sas7bdat ) because it uses the Reference to good as "C:/Data/"; in previous step.

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
Microsoft Excel
Microsoft Excel is a proprietary commercial spreadsheet application written and distributed by Microsoft for Microsoft Windows and Mac OS X. It features calculation, graphing tools, pivot tables, and a macro programming language called Visual Basic for Applications...

, Rich Text (Word
Word
In language, a word is the smallest free form that may be uttered in isolation with semantic or pragmatic content . This contrasts with a morpheme, which is the smallest unit of meaning but will not necessarily stand on its own...

) 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
Microsoft Excel
Microsoft Excel is a proprietary commercial spreadsheet application written and distributed by Microsoft for Microsoft Windows and Mac OS X. It features calculation, graphing tools, pivot tables, and a macro programming language called Visual Basic for Applications...

 files, .pdf for Adobe Acrobat
Adobe Acrobat
Adobe Acrobat is a family of application software developed by Adobe Systems to view, create, manipulate, print and manage files in Portable Document Format . All members of the family, except Adobe Reader , are commercial software, while the latter is available as freeware and can be downloaded...

 files,.doc for Microsoft Word
Microsoft Word
Microsoft Word is a word processor designed by Microsoft. It was first released in 1983 under the name Multi-Tool Word for Xenix systems. Subsequent versions were later written for several other platforms including IBM PCs running DOS , the Apple Macintosh , the AT&T Unix PC , Atari ST , SCO UNIX,...

 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
SQL
SQL is a programming language designed for managing data in relational database management systems ....

 with suffix 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
SAS System
SAS is an integrated system of software products provided by SAS Institute Inc. that enables programmers to perform:* retrieval, management, and mining* report writing and graphics* statistical analysis...

) 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
SAS System
SAS is an integrated system of software products provided by SAS Institute Inc. that enables programmers to perform:* retrieval, management, and mining* report writing and graphics* statistical analysis...

 has increasingly become a generic platform for elaborate products such as SAS/EM, SAS/Intrnet, and SAS/Access engines.

Attributed-SAS Archives Discussion

Controversy

There has been controversy lately on difference if any on SAS as a language and SAS as a system. While some people believe that SAS exists as a language and cannot be copyrighted by the SAS Institute only. This is because of third party compilers like WPS from World Programming System
World Programming System
The World Programming System, also known as WPS, is a software product developed by a company called World Programming. WPS allows users to create, edit and run programs written in the language of SAS. The latest release of WPS covers a significant gap in use of WPS. It now provides PROC REG and...

, GNU DAP (software)
DAP (software)
Dap is a statistics and graphics program, that performs data management, analysis, and graphical visualization tasks which are commonly required in statistical consulting practice....

, and Carolina from Dulles Open and SAS Institute's efforts to be the sole distributor of the SAS language related products.In addition the SAS Institute created a wiki with the condition that any content there is irrevocably and permanently licensed to the SAS Institute. The SAS Institute also hosts and funds some part of the annual SAS User Group Conference with the same condition that all content is irrevocably and permanently licensed to the SAS Institute.

In a recent judgement by High Court in UK, SAS Language was established as a programming language.

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK