Learn SAS Programming
Learn SAS Programming
Learn SAS Programming
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.
Introduction to SAS
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
These books coupled with SUGI Papers will give you the impetus/basics to learn and explore more on the Internet.
Here are some links to SAS statements and its options in the SAS Documentation...
SAS Options
SAS Statements
SAS Procedures
SAS Functions
SAS Simple STATs
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 :-)
Well...there are many ways of getting the observation count into a macro variable...but there a few pros and cons in those
methods...
2. datastep
eg.
data new;
set old nobs=num;
call symputx('macvar',num);
run;
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)
%macro split(dsn,splitby);
data _null_;
set &dsn nobs=num;
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
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....
data flags;
set sashelp.flags;
a=2;
b=4;
Here are some more links for SAS Interview Questions and Answers found on the Internet...
http://www.sconsig.com/tipscons/list_sas_tech_questions.htm
http://www.globalstatements.com/sas/jobs/technicalinterview.html
http://studysas.blogspot.com
What SAS statements would you code to read an external raw data file to a DATA step?
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.
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.
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...
%macro organizeGoogleContacts(infile,outfile);
/*Import your contacts into SAS */
data googlegroups;
infile "&infile" dlm=',' dsd lrecl=32767 firstobs=2;
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.23
2 Michael 45.68
3 Tammy 53.21
;
A document that discusses How can I create a CSV file with ODS?
A document that discusses Use a Microsoft Excel file to create a user-defined format
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 -----------
http://www.sastips.com/
http://www.afhood.com/blog/
http://www.thejuliagroup.com/blog/
Here's a macro that reads the filenames available at a particular directory on any FTP server (i.e. Windows Network
Drive/Unix/Mainframe)...