learn sas programming

35
What is SAS? The SAS BI Software The SAS BI System is an integrated suite of software for enterprise-wide information delivery... Applications of the SAS System include executive information systems; data entry, retrieval, and management; report writing and graphics; statistical and mathematical analysis; business planning, forecasting, and decision support; operations research and project management; statistical quality improvement; computer performance evaluation; and applications development. Read more @ http://sastechies.blogspot.com/2009/11/what-is-sas.html Introduction to SAS Read more @ http://sastechies.blogspot.com/2009/11/introduction-to-sas.html What is SAS system? The SAS System known well as Statistical Analysis System, is one of the most widely used, flexible data processing, reporting and analyses tools. SAS is a set of solutions for enterprise-wide business users as well as a powerful fourth- generation programming language for performing tasks or analyses in a variety of realms such as these: -

Upload: sastechies

Post on 16-Nov-2014

39 views

Category:

Documents


2 download

DESCRIPTION

Learn SAS programming, SAS slides, SAS tutorials, SAS certification, SAS Sample Code, SAS Macro examples,SAS video tutorials, SAS ebooks, SAS tutorials, SAS tips and Techniques, Base SAS and Advanced SAS certification, SAS interview Questions and answers, Proc SQL, SAS syntax, Advanced SAS, Quick links, SAS Documentation, SAS Addin to Microsoft office, Oracle, ODS HTML, ODS

TRANSCRIPT

Page 1: Learn SAS Programming

What is SAS?

The SAS BI Software

The SAS BI System is an integrated suite of software for enterprise-wide information delivery... Applications of the SAS System include executive information systems; data entry, retrieval, and management; report writing and graphics; statistical and mathematical analysis; business planning, forecasting, and decision support; operations research and project management; statistical quality improvement; computer performance evaluation; and applications development.

Read more @ http://sastechies.blogspot.com/2009/11/what-is-sas.html

Introduction to SAS

Read more @ http://sastechies.blogspot.com/2009/11/introduction-to-sas.html

What is SAS system?

 The SAS System known well as Statistical Analysis System, is one of the most widely used, flexible data processing, reporting and analyses tools.

SAS is a set of solutions for enterprise-wide business users as well as a powerful fourth-generation programming language for performing tasks or analyses in a variety of realms such as these: -

Analytic Intelligence General Data Mining and Statistical Analysis Forecasting & Econometrics Operations Research

Read more @ http://sastechies.blogspot.com/2009/11/introduction-to-sas.html

Page 2: Learn SAS Programming

SAS Books Recommended for industry application

These books coupled with SUGI Papers will give you the impetus/basics to learn and explore more on the Internet.

1. Professional SAS Programmer's Pocket Reference - Rick Aster       This book would be a must for any SAS Professional I guess.....It's a quick handy book for Syntax and  options......

2. SAS Certification Prep Guide: Base Programming - SAS Institute      This book is a Prep Guide for BaseSAS....I would suggest you to read the whole book before you attempt the exam in addition to the SAS Online tutor, as it covers some uncovered syllabus on the latter....

3. Cody's Data Cleaning Techniques Using SAS Software - Ron Cody       This book is an excellent source of examples of SAS in real-world applications....

Read more @ http://sastechies.blogspot.com/2009/11/sas-books-recommended-for-industry.html

Page 3: Learn SAS Programming

Base SAS tutorials (Slides) for the Beginners !!! ...

Here are some links to learning Base SAS...

SAS Slides 1 : Introduction to SAS

Read more @ http://sastechies.blogspot.com/2009/11/base-sas-tutorials-slides-for-beginners.html

Page 4: Learn SAS Programming

Advanced SAS tutorials (Slides) for Beginners !!!

Here are some links to learning Advanced SAS Programming...

SAS Macros - to learn Macro Programming in SAS.

SAS Slides 12 : Macros

Read more @ http://sastechies.blogspot.com/2009/11/advanced-sas-tutorials-slides-for.html

Page 5: Learn SAS Programming

Quick links to SAS Statements in SAS Documentation...

Here are some links to SAS statements and its options in the SAS Documentation...

SAS OptionsSAS StatementsSAS ProceduresSAS FunctionsSAS Simple STATs

Read more @ http://sastechies.blogspot.com/2009/11/quick-links-to-sas-statements-in-sas.html

Page 6: Learn SAS Programming

Base SAS tutorials (Slides) for the Beginners !!! ...

SAS Slides 7 : Match Merging with Datastep

Read more @ http://sastechies.blogspot.com/2009/11/base-sas-tutorials-slides-for-beginners_13.html

Page 7: Learn SAS Programming

SAS macro to Create / Remove a PC Directory...

Here's a SAS macro to Create and Remove a PC Directory... Often we ignore Notes and warning in the SAS log when we try to create/remove a directory that does/doesn't exist...This macro first checks for the existence of the directory and then create/delete it or else put a message to the SAS log...try it out :-)

/* Macro to Create a directory */

%macro CheckandCreateDir(dir);    options noxwait;    %local rc fileref ;    %let rc = %sysfunc(filename(fileref,&dir)) ;       %if %sysfunc(fexist(&fileref)) %then       %put The directory "&dir" already exists ;    %else      %do ;          %sysexec mkdir "&dir" ;          %if &sysrc eq 0 %then %put The directory &dir has been created. ;

Read more @ http://sastechies.blogspot.com/2009/11/sas-macro-to-remove-pc-directory.html

Page 8: Learn SAS Programming

Ways to Count the Number of Obs in a dataset and pass it into a macro variable...

Well...there are many ways of getting the observation count into a macro variable...but there a few pros and cons in those methods...

1. using sql with count(*)..  eg.         proc sql;              select count(*) into :macvar             from dsn;         quit;

 pros: simple to understand and develop cons: you need to read the dataset in its entirety which requires processing power here...

2. datastep  eg.        data new;          set old nobs=num;          call symputx('macvar',num);       run;

Read more @ http://sastechies.blogspot.com/2009/11/ways-to-count-number-of-obs-in-dataset.html

Page 9: Learn SAS Programming

SAS macro to split dataset by the number of Observations specified

Suppose there was a large dataset....This SAS macro program splits the dataset by the number of observations mentioned...

macro name%split(DatasetName, No ofobservation to split by)

/* creating a dataset with 100000 observations*/

data dsn;do i=1 to 100000;output;end;run;

%macro split(dsn,splitby);data _null_;set &dsn nobs=num;

Read more @ http://sastechies.blogspot.com/2009/11/sas-macro-to-split-dataset-by-number-of.html

Page 10: Learn SAS Programming

SAS Programming Efficiencies

The purpose of this document is to provide tips for improving the efficiency of your SAS programs. It suggests coding techniques, provides guidelines for their use, and compares examples of acceptable and improved ways to accomplish the same task. Most of the tips are limited to DATA step applications.   Efficiency   For the purpose of this discussion, efficiency will be defined simply as obtaining more results from fewer computer resources. When you submit a SAS program, the computer must: 

load the required software into memory  compile the program 

Read more @ http://sastechies.blogspot.com/2009/11/sas-programming-efficiencies.html

Page 11: Learn SAS Programming

SAS macro to reorder dataset variables in alphabetic order...

How do you reorder variables in a dataset...I get this many a times....

Here's a macro for you to achieve it...For example I've used a dataset sashelp.flags and created some more variables with variety of variables with names upper / lower cases and _'s to demonstrate the reorder macro....

 

Please try this macro for yourself and let me know your suggestions....

 

/* Example dataset with variety of variable names */

 

data flags;

set sashelp.flags;

a=2;

b=4;

Read more @ http://sastechies.blogspot.com/2009/11/sas-macro-to-reorder-dataset-variables.html

Page 12: Learn SAS Programming

SAS Interview Questions and Answers found on the Internet...

Here are some more links for SAS Interview Questions and Answers found on the Internet...

http://www.sconsig.com/tipscons/list_sas_tech_questions.htmhttp://www.globalstatements.com/sas/jobs/technicalinterview.html http://studysas.blogspot.com

Read more @ http://sastechies.blogspot.com/2009/11/sas-interview-questions-and-answers.html

SAS Interview Questions and Answers(1)

What SAS statements would you code to read an external raw data file to a DATA step?

We use SAS statements –

FILENAME – to specify the location of the file

INFILE - Identifies an external file to read with an INPUT statement

INPUT – to specify the variables that the data is identified with.

Read more @ http://sastechies.blogspot.com/2009/11/sas-interview-questions.html

Page 13: Learn SAS Programming

SAS Interview Questions and Answers(2)

If you're not wanting any SAS output from a data step, how would you code the data statement to prevent SAS from producing a set?

Data _null_;

 

 _NULL_ - specifies that SAS does not create a data set when it executes the DATA step.

 

Data _null_ is majorly used in

 o creating quick macro variables with call symput routine

eg.            Data _null_;             Set somedata;             Call symput(‘macvar’,dsnvariable);         Run;

o Creating a Custom Report Eg.

Read more @ http://sastechies.blogspot.com/2009/11/sas-interview-questions-and-answers2.html

Page 14: Learn SAS Programming

Advanced Macro Topics

A document that discusses Advanced Macro topics

Read more @ http://sastechies.blogspot.com/2009/11/advanced-macro-topics.html

Page 15: Learn SAS Programming

SAS Instructor's Programming Tip - Combining Data ...

Read more @ http://sastechies.blogspot.com/2009/11/sas-instructors-programming-tip.html

Opening SAS Data Files - A video tutorial

Read more @ http://sastechies.blogspot.com/2009/11/opening-sas-data-files-video-tutorial.html

SAS Add-in to Microsoft Office

SAS Add-In for Microsoft Office enables business users to trans-parently leverage the power of SAS data access, reporting and analytics directly from Microsoft Office via integrated menus and toolbars.

SAS Add-in to Microsoft Office Video Tutorial 1

SAS Add-in to Microsoft Office Video Tutorial 2

A document that discusses SAS Add-in to Microsoft Office

Read more @ http://sastechies.blogspot.com/2009/11/sas-add-in-to-microsoft-office.html

Page 16: Learn SAS Programming

SAS Certification Preparation Guide for SAS 9

SAS Certification Preparation Guide

Read more @ http://sastechies.blogspot.com/2009/11/sas-certification-preparation-guide-for.html

Page 17: Learn SAS Programming

SAS Publishing - SAS 9.1 Programming I & II Course...

Sas Publishing - Sas 9.1 Programming I Essentials Course Notes (2005)

Read more @ http://sastechies.blogspot.com/2009/11/sas-publishing-sas-91-programming-i.html

Page 18: Learn SAS Programming

Use SAS function Propcase() to streamline Google Contacts

You might think I am crazy...but I have been using this macro for a long time to fix some contacts in my Google Contacts...I get a little irritated when I can't find a particular person by email...so I wrote this macro...This macro takes for Input a .csv file that is exported from Google Contacts and outputs a file that is ready to be imported to Google Contacts....often I wanted to have Names in the proper case...

Try it yourself and let me know if it needs any tweaks...

Propcase in SAS Documentation.

%macro organizeGoogleContacts(infile,outfile);/*Import your contacts into SAS */ data googlegroups;infile "&infile" dlm=',' dsd lrecl=32767 firstobs=2;

Read more @ http://sastechies.blogspot.com/2009/11/use-sas-function-propcase-to-streamline.html

Page 19: Learn SAS Programming

SAS Macro to Create a delimited text file from a SAS dataset...

A document that discusses SAS Macro to Create a delimited text file from a SAS data set..

options mprint; data one;  input id name :$20. amount ;  date=today();  format amount dollar10.2            date mmddyy10.;  label id="Customer ID Number";datalines;1 Grant   57.232 Michael 45.683 Tammy   53.21;

Read more @ http://sastechies.blogspot.com/2009/11/sas-macro-to-create-delimited-text-file.html

Page 20: Learn SAS Programming

How can I create a CSV file with ODS?

A document that discusses How can I create a CSV file with ODS?

/* example 1: Release 8.1 */    ods xml body='c:\test\test.csv' type=csv;   proc print data=sashelp.class;   run;   ods xml close;

Read more @ http://sastechies.blogspot.com/2009/11/how-can-i-create-csv-file-with-ods.html

Use a Microsoft Excel file to create a user-defined format

A document that discusses Use a Microsoft Excel file to create a user-defined format

/*Create an Excel spreadsheet for the example. */

filename test 'c:\testfmt.csv';proc export data=sashelp.class outfile=test  dbms=csv replace;run;

Read more @ http://sastechies.blogspot.com/2009/11/use-microsoft-excel-file-to-create-user.html

Page 21: Learn SAS Programming

SAS Macro to split a dataset into multiple datasets vertically with a common primary key

This macro splits a dataset to multiple datasets vertically with a common primary key. For eg, a dataset has 400 fields and 20,000 records. If we can split the dataset into two, with 200 fields and 20,000 records in each dataset with a common field like loan number as primary key would be helpful to load the details for analysis.

 

/**

To be called like this...

%splitdsnverticallykey(dsn,varperdsn,keyvars=);

eg. %splitdsnverticallykey(sashelp.vtable,4,keyvars=memname libname);

 

Where -----------

 

dsn - libname.datasetname to be split

varperdsn - How many vars per dsn excluding the key variables

keyvars - specify the primary key variables

*/ Read more @ http://sastechies.blogspot.com/2009/11/sas-macro-to-split-dataset-into.html

Page 22: Learn SAS Programming

SAS Certification Base SAS Practice Exam

SAS BASE Programming Exam

Read more @ http://sastechies.blogspot.com/2009/11/sas-certification-base-sas-practice.html

Page 23: Learn SAS Programming

SAS Certification Advanced SAS Practice Exam

Sample Advanced SAS Exam

Read more @ http://sastechies.blogspot.com/2009/11/sas-certification-advanced-sas-practice.html

Page 24: Learn SAS Programming

Other interesting SAS Blogs for references...

Here are some other interesting SAS Blogs for references...

http://www.sastips.com/

http://www.afhood.com/blog/

http://www.thejuliagroup.com/blog/

Read more @ http://sastechies.blogspot.com/2009/11/other-interesting-sas-blogs-for.html

Page 25: Learn SAS Programming

SAS Macro that reads the filenames available at a particular directory on any FTP server (i.e. Windows Network Drive/Unix/Mainframe)

Here's a macro that reads the filenames available at a particular directory on any FTP server (i.e. Windows Network Drive/Unix/Mainframe)...

For Windows network drives we use the Filename Pipe StatementFor Mainframe and Unix we use the FileName FTP protocol statement.

For further reference please refer to Filename statements in SAS Documentation.

First we need to create 2 Excel files

ServerList.xls – 3 columns with servertype | host | sourcedir

Read more @ http://sastechies.blogspot.com/2009/11/sas-macro-that-lists-files-at.html