SAS编程入门介绍
日期:2012/02/06 来源:GBin1.com
1.Why to learn SAS?
Everyone has his/her own answer. But if you want to work with SAS, you should learn it.
2.Where to use SAS?
Data process, analysis and presentation.
3.IDE
- Enterprise Guide
- Eclipse SAS Editor Plugin (for java programmers)
- WPS (I have never used it.)
- Enhanced Editor (for experienced SAS programmers)
4.Core SAS
产品
- BASE SAS
- SAS Products for analysis, such as SAS/STAT, SAS/ETS and SAS/OR
- SAS/GRAPH
基本 (SAS E-Learning):
Advanced (SAS E-Learning):
Points
- libref
- fileref
- sas files (data set, view, index, catalog)
- data step concepts (data set, variable, pdv, loop)
- data import and export
- data step plus infile
- proc import
- libname (database, excel, access, pcfiles, webdav, xml)
- Import wizard (You may use it to generate SAS code if you are not familiar with SAS programming.)
- data step plus file
- proc export
- libname (database, excel, access, pcfiles, webdav, xml)
- Export wizard (You may use it to generate SAS code if you are not familiar with SAS programming.)
- ODS
- formats and informats
- Where to use it?
- Importing and exporting data, summary, lookup, presentation.
- How to generate it?
- Proc format
- Proc format cntlin=SAS data set
- It supports multi label and this is very useful when you summarize data.
- hash
- array
- functions and call routines
- most commonly-used procedures such as sort, summary etc.
- proc sql
- macro (macro variable, macro, debug, compiled macro, quote)
- SAS Graph, ODS Graphics, ODS Graphics Designer
- ODS report
- SAS System
- system options
- system reserved variables (_n_, _error_, _numeric_, _character_, _all_, _infile_, _last_, _null_, _data_)
- _n_, _error_
- _numeric_, _character_, _all_
- _infile_
- _last_: the most recently created SAS data set.
- _null_, _data_: reserved SAS data set name
- system views under SAShelp
- system procedures (proc options, proc javainfo, proc setinit)
Misc.
- Publishing Framework (SAS Integration Technologies)
- ODS Package
- Package Retriever (SAS Integration Technologies)
- Encryption (encrypt password)
- Sharepoint (xml and PROC SOAP)
Enterprise Guide (resource to get SAS code to do analysis or generate graph and ODS report)
DI Studio (resource to get SAS code to import various data)
5.Advanced SAS Programming
- Efficient SAS program
- Strongly recommend to read SAS published books about this topic, since some principles are suitable for other analysis languages as well.
- Performance tuning
- http://support.SAS.com/rnd/base/datastep/dot/better-hashing-SAS92.pdf
- http://support.SAS.com/rnd/base/datastep/dot/hash-getting-started.pdf
- Tips
- There is no shortest route. Only continuous learning and summarizing is the route.
6.Required Knowledge for SAS Staff
- SAS naming conventions
- Portable code (one code, runnable on all operating systems)
- Multi-language support aka NLS
7. SAS Intelligence Platform
- Introduction to the SAS Intelligence Platform: System Administration Guide
- Metadata Server
- Application Server
- Overview of Other SAS Servers and Spawners
- SAS® 9.3 Language Interfaces to Metadata
- Base SAS® 9.3 Guide to Information Maps
- SAS Stored Process: Developer’s Guide
8.Integration with other languages (SAS Integration Technologies)
SAS can do everything, but sometimes it is not easy or suitable to do some processes using SAS, so the only method to figure out the best way is to learn more about SAS and integration as well.
- In-database model publish (run SAS model via SQL after publish)
- PROC PSCORE (PMML model support)
- PROC IML (R language support)
- JAVA Data Step Object (run java code in SAS)
- PROC Groovy
PROC GROOVY can run Groovy statements that are written as part of your SAS code, and it can run statements that are in files that you specify with PROC GROOVY commands. It can parse Groovy statements into Groovy Class objects, and run these objects or make them available to other PROC GROOVY statements or Java DATA Step Objects.
proc groovy classpath=cp;
submit parseonly;
class Speaker {
def say( word ) {
println "----> \"${word}\""
}
}
endsubmit;
quit;
proc groovy classpath=cp;
eval "s = new Speaker(); s.say( ""Hi"" )";
quit;
The finance analyst is always working with equations, or many equations. Obviously here SAS is not good at it. Yes, SAS has more than 900 functions. And they are still not enough to keep up with the fast-pace of Wall Street. That is why the quants use Matlab, C++ and Excel VBA, instead of SAS. http://www.SASanalysis.com/2010/10/from-vba-to-proc-fcmp-in-SAS.html
The PROTO procedure provides a simple interface to register external functions written in C/C++ for use in SAS. All functions registered in proc PROTO can be then used in FCMP. Proc Fcmp is a formidable tool for building function and even function library.
- Command line mode
9. Grid Computing and High Performance Computing
- Advanced data storage and access engine (SPDE and SAS Table Server)
- SAS Scalable Performance Data Engine (SPDE)
- Grid computing
- Enabling SAS Applications to Run on a Grid
- Procedure SCAPROC - SAS Code Analyzer Procedure
- Thoroughly Modern SAS: The SAS Code Analyzer Helps Bring Programs Up to Date
- Data Step 2 (DS2, next generation of data step language)
- High Performance Computing
- The Vision for HPA Architecture
- HPLOGISTIC: logistic regression and variable selection.HPREG: linear regression and variable selection.
HPLMIXED: linear mixed models.
HPNEURAL: neural nets.
HPNLIN: nonlinear regression and maximum likelihood.
HPREDUCE: covariance/correlation analysis, variable reduction.
HPDMDB: summarization.
HPSUMMARY: descriptive statistics.
HPFOREST: predictive modeling based on decision trees.
HPDS2: next-generation DATA step.
10.Drawbacks of SAS language
- Process-oriented not object-oriented (It should be its characteristic rather than drawback.)
- Exception handling
- Transaction support (rollback)
11. Four phases of SAS programming
- Runnable SAS codes for a specific problem
- Runnable SAS macros for general problems
- Complicated design and data-driven code generator
- Clear design and effective code
12.Books you’d better read
- Basic (SAS E-Learning):
- SAS Programming 1
- SAS Programming 2
- Advanced (SAS E-Learning):
- SAS Programming 3
- SAS Macro Language
- SAS SQL
- Little SAS Book (Good for learner, recommended by many people.)
- SAS Programming by Example (Good for learner, recommended by many people.)
- Efficiency: Improving the Performance of Your SAS Applications
- In the Know...SAS Tips and Techniques From Around the Globe
- SAS Foundation new features and other SAS products introduction (you need to read SAS Help documents or New Feature introduction documents quite often.)
13. The End
SAS system is more than above lists (>1000 functions and >350 procedures), so learning and practicing is the power to know SAS.
关于作者
Emily Gao目前就职于SAS北京研发中心,负责领导一个开发团队进行 SAS Model Manager 相关的开发工作,拥有8年SAS开发经验,如果你需要联系她,请发送邮件到
电子邮件:hhshnsq@hotmail.com
个人博客: 爱美丽高
来源: SAS编程入门介绍



