-
http://www.puzha.com/sasbook/sas%20examples.html
Best site to learn SAS with examples.
-
https://sites.google.com/site/sasbuddy/sas-interview-questions
Best site For Interview Questions.
-
http://clinicalprogrammers.blogspot.in/2012/05/adverse-event-tables-continued.html
Best site For Clincical Programmers.
-
http://www.unt.edu/rss/class/sas1/
A good site For SAS Programmers with screen shots.
-
https://sites.google.com/site/sasbuddy/infile-statement-options-flowover-truncover-missover-stopover
A good site for simple definations on sas.
-
http://studysas.blogspot.in/2008/08/sas.html
A good site with excellent examples on Base sas.
-
http://www.ats.ucla.edu/stat/sas/modules/default.htm
One of the best site to learn SAS.
-
http://www.people.vcu.edu/~rjohnson/bios524/Cody%20Notes/index.html
Biostatistical Computing using SAS at VCU university.
-
http://www.people.vcu.edu/~rjohnson/bios524/sample_programs.htm
-
http://www.globalstatements.com/sas/defined/index.html
-
http://www.indiana.edu/~statmath/stat/sas/win/index.html
- http://www.ciser.cornell.edu/computing/SASQA.shtml
sas
Thursday, 16 May 2013
Learning SAS From Free Best Websites And Materials
There are so many people wanted to learn SAS for free. The following are the small list of websites where you can find Free Reading Materials .
Monday, 6 May 2013
Introduction To Sas Basics
What is Sas ?
What is Sas Usage?
•Started in late 1970s
•Used extensively at academic and business environments (medical device and pharmaceutical companies)
•Most analyses of publications in medical journals use SAS
A SAS Program consists of a series of SAS statements which are used to define, read in, manipulate, and analyze data. The typical SAS program is organized into three parts:
There are two main components to most SAS programs
Data Step: Basics Each data step begins with the word data and optionally one or more data set names (and associated options) followed by a semicolon. The name(s) given on the data step are the names of data sets which will be created within the data step.
If you don’t include any names on the data step, SAS will create default data set names of the form datan, where n is an integer which starts at 1 and is incremented so that each data set created has a unique name within the current session. Since it becomes difficult to keep track of the default names, it is recommended that you always explicitly specify a data set name on the data statement.
When you are running a data step to simply generate a report, and don’t need to create a data set, you can use the special data set name _null_ to eliminate the output of observations.
Data Step: Inputting Data The input statement of SAS is used to read data from an external source, or from lines contained in your SAS program.
The infile statement names an external file or fileref∗ from which to read the data; otherwise the cards; or datalines; statement is used to precede the data.
data one;
infile "input.data";
input a b c;
run;
Reading data from an external file
data one;
input a b c;
datalines;
. . .
;
Reading from inline data By default, each invocation of the input statement reads another record. This example uses free-form input, with at least one space between values.
∗A fileref is a SAS name, created by the filename statement, which refers to an external file or other device
Data Step: input Statement There are three basic forms of the input statement:
Summary of DATA STEP
Accessing SAS
There are four ways to access SAS on a UNIX system:
- SAS is a programming language that reads the data from a variety of file formats like Excel, flat file, dBase, Lotus,existing SAS dataset(s), or a file produced by another software program. whatever the data SAS has reads , first it will process and then it will performs analyses on the same data .
- SAS gives support for data access, data management, data analysis, and data presentation.
- SAS helps you to perform many analyses on your PCs
- Now SAS is the most widely used statistical software .
- SAS stand for “Statistical Analysis System” and it pronounced as “sass”, not spelled out as three letters.
- Originally it intended for management and analysis of agricultural field experiments
What is Sas Usage?
•Started in late 1970s
•Used extensively at academic and business environments (medical device and pharmaceutical companies)
•Most analyses of publications in medical journals use SAS
A SAS Program consists of a series of SAS statements which are used to define, read in, manipulate, and analyze data. The typical SAS program is organized into three parts:
- Data Definition and Options
Define the data location and the environment. - Data Step
Read, modify, subset, and write the data - Procedure(s)
Perform an action on the data
e.g. sort the data, compute means, run a regression, etc.
There are two main components to most SAS programs
- Data step(s)
- Procedure step(s).
- The data step reads data from external sources, manipulates and combines it with other data set and prints reports.
-
The data step is used to prepare your data for use by one of the procedures
(often called “procs”).
Data Step: Basics Each data step begins with the word data and optionally one or more data set names (and associated options) followed by a semicolon. The name(s) given on the data step are the names of data sets which will be created within the data step.
If you don’t include any names on the data step, SAS will create default data set names of the form datan, where n is an integer which starts at 1 and is incremented so that each data set created has a unique name within the current session. Since it becomes difficult to keep track of the default names, it is recommended that you always explicitly specify a data set name on the data statement.
When you are running a data step to simply generate a report, and don’t need to create a data set, you can use the special data set name _null_ to eliminate the output of observations.
Data Step: Inputting Data The input statement of SAS is used to read data from an external source, or from lines contained in your SAS program.
The infile statement names an external file or fileref∗ from which to read the data; otherwise the cards; or datalines; statement is used to precede the data.
data one;
infile "input.data";
input a b c;
run;
Reading data from an external file
data one;
input a b c;
datalines;
. . .
;
Reading from inline data By default, each invocation of the input statement reads another record. This example uses free-form input, with at least one space between values.
∗A fileref is a SAS name, created by the filename statement, which refers to an external file or other device
Data Step: input Statement There are three basic forms of the input statement:
-
List input (free form)
data fields must be separated by at least one blank. List the names of the variables, follow the name with a dollar sign ($) for character data.
-
Column input
It follow the variable name (and $ for character) with startingcolumn – endingcolumn. -
Formatted input
Optionally precede the variable name with @startingcolumn; follow the variable name with a SAS format designation. (Examples of formats: $10. (10 column character), 6. (6 column numeric)) When mixing different input styles, note that for column and formatted input, the next input directive reads from the column immediately after the previous value, while for list input, the next directive reads from the second column after the previous value.
-
The procedure steps perform analysis on the data, and produce
(often huge amounts of) output.
Summary of DATA STEP
- Reads in and processes your raw data and makes a SAS dataset.
- Performs specific statistical analyses
- Some procedures are utility procedures such as PROC SORT that is used to sort your data
Accessing SAS
There are four ways to access SAS on a UNIX system:
-
Type sas
This opens the SAS “display manager”, which consists of three windows (program, log, and output). Some procedures must be run from the display manager. -
Type sas -nodms
You will be prompted for each SAS statement, and output will scroll by on the screen. - Type sas -stdio SAS will act like a standard UNIX program, expecting input from standard input, sending the log to standard error, and the output to standard output;
- Type sas filename.sas This is the batch mode of SAS - your program is read from filename.sas, the log goes to filename.log and the output goes to filename.lst.
|
Read in Data
Process Data (Create new variables) Output Data (Create SAS Dataset) |
-->Data Step
|
--->PROCs
Structure of Data
- Made up of rows and columns
- Rows in SAS are called observations
- Columns in SAS are called variables
- Together they make up the dataset (table)
- An observation (row) is all the information for one entity (patient, patient visit, clinical center, county)
- SAS processes data one observation at a time
12 observations (rows) and 5 variables (columns)
F   23   S   15   MN
F   21   S   15   WI F   22   S   09   MN F   35   M   02   MN F   22   M   13   MN F   25   S   13   WI M   20   S   13   MN M   26   M   15   WI M   27   S   05   MN M   23   S   14   IA M   21   S   14   MN M   29   M   15   MN |
Types of Variables In SAS
- Numeric     (e.g. age, blood pressure) -- 54, 140
- Character     (patient ID, diagnosis) -- A001, TIA, 0410
Rules for SAS Statements
-
SAS statements end with a semicolon (;)
- SAS variable names must be 32 characters or less, constructed of letters, digits and the underscore character. (Before version 7, the limit was 8.)
-
SAS is not case sensitive, except inside of quoted strings.
Starting in Version 7, SAS will remember the case of variable
names when it displays them.
-
Missing values are handled consistently in SAS, and are
represented by a period (.).
-
It’s a good idea not to start variable names with an underscore,
because special system variables are named that way.
-
Data set names follow similar rules as variables, but they have
a different name space.
Example
DATA demo; -
SAS statements can be entered in lower or uppercase
Example For Lower Case Declaration
data demo;
infile datalines;
input gender $ age;
Example For Upper Case Declaration
DATA DEMO;
INFILE DATALINES;
INPUT GENDER $ AGE;
- Multiple SAS statements can appear on one line
- Variable names can be from 1-32 characters and must begin with A-Z or an underscore (_). No special characters except underscore is allowed.
- dbp12
- DiastolicBloodPressure
- _dbp12
- 12dbp
- dbp 12
- dbp-12
INFILE DATALINES;
INPUT gender $ age;
Example
DATA demo; INFILE DATALINES; INPUT gender $ age; X1 = 0; X2 = 0; X3 = 0; X4 = 0;A SAS statement can use multiple lines INPUT gender $ age marstat;
SYNTAX IS CORRECT FOR FOLLOWING VARIABLE NAMES
SYNTAX IS INCORRECT FOR FOLLOWING VARIABLE NAMES
| DATA
demo;
    INFILE DATALINES;     INPUT gender $ age marstat $ credits state $ ;     if credits > 12 then fulltime = 'Y'; else fulltime = 'N';     if state = 'MN' then resid = 'Y'; else resid = 'N'; Datalines;
F   23   S   15   MN
;F   21   S   15   WI F   22   S   09   MN F   35   M   02   MN F   22   M   13   MN F   25   S   13   WI M   20   S   13   MN M   26   M   15   WI M   27   S   05   MN M   23   S   14   IA M   21   S   14   MN M   29   M   15   MN Run ; |
| PROC PRINT DATA=demo ;     VAR gender age marstat credits fulltime state ; RUN; PROC MEANS DATA =demo; PROC FREQ DATA=demo; |
-
DATA demo;
    Create a SAS dataset called demo
-
INFILE DATALINES;    
Where is the data?
-
INPUT gender $
age
marstat $
credits
state $ ;
What are the variable names and types?
- if credits > 12 then fulltime = 'Y'; else fulltime = 'N';
-
if
state = 'MN'
then
resid = 'Y';
else
resid = 'N';
Statements 4 and 5 create 2 new variables -
DATALINES;
Tells SAS the data is coming
F   23   S   15   MN
F   21   S   15   WI
F   22   S   09   MN
F   35   M   02   MN
F   22   M   13   MN
F   25   S   13   WI
M   20   S   13   MN
M   26   M   15   WI
M   27   S   05   MN
M   23   S   14   IA
M   21   S   14   MN
M   29   M   15   MN
;Tells SAS the data is ended
-
RUN;
Tells SAS to run the statements above
- PROC PRINT DATA=demo ;
- VAR gender age marstat credits fulltime state ;
-
RUN;
Tells SAS to display the listed variables
Main SAS Windows (PC)
Editor Window-
This window allows you to write your SAS programs and submit your programs by clicking on run icon to execute.
- This window displays the notes of SAS sessions, and tells you any errors, warnings after you submit your SAS programs.
- Always look at the log window !
- Tells how SAS understood your program
- index to all of your output
Messages in SAS Log
Errors
- fatal in that program will abort
- messages that may or may not be important
* This is a short example program to demonstrate what a SAS program looks like. This is a comment statement because it begins with a * and ends with a semi-colon ;
| DATA
demo;
    INFILE DATALINES;     INPUT gender $ age marstat $ credits state $ ;     if credits > 12 then fulltime = 'Y'; else fulltime = 'N';     if state = 'MN' then resid = 'Y'; else resid = 'N'; Datalines;
F   23   S   15   MN
;F   21   S   15   WI F   22   S   09   MN F   35   M   02   MN F   22   M   13   MN F   25   S   13   WI M   20   S   13   MN M   26   M   15   WI M   27   S   05   MN M   23   S   14   IA M   21   S   14   MN M   29   M   15   MN Run ; TITLE 'Running the Example Program'; |
| PROC PRINT DATA=demo ;     VAR gender age marstat credits fulltime state ; RUN; |
LOG WINDOW (or file)
NOTE: Copyright (c) 1999-2001 by SAS Institute Inc., Cary, NC, USA.NOTE: SAS (r) Proprietary Software Release 8.2 (TS2M0)       Licensed to UNIVERSITY OF MINNESOTA, Site 0009012001.
NOTE: This session is executing on the WIN_NT platform.
NOTE: SAS initialization used:
      real time     7.51 seconds
      cpu time     0.89 seconds
1   * This is a short example program to demonstrate what a
2   SAS program looks like. This is a comment statement because
3   it begins with a * and ends with a semi-colon ;
4  
5   DATA demo; 6   INFILE DATALINES;
7   INPUT gender $ age marstat $ credits state $ ;
8  
9   if credits > 12 then fulltime = 'Y'; else fulltime = 'N'; 10   if state = 'MN' then resid = 'Y'; else resid = 'N'; 11   Datalines; NOTE: The data set WORK.DEMO has 12 observations and 7 variables.
NOTE: DATA statement used:
        real time 0.38 seconds
        cpu time 0.06 seconds
25 RUN;
26 TITLE 'Running the Example Program';
27 PROC PRINT DATA=demo ;
28 VAR gender age marstat credits fulltime state ;
29 RUN;
NOTE: There were 12 observations read from the data set WORK.DEMO.
NOTE: PROCEDURE PRINT used:
    real time     0.19 seconds
    cpu time     0.02 seconds
30 PROC MEANS DATA=demo N SUM MEAN;
31 VAR age credits ;
32 RUN;
NOTE: There were 12 observations read from the data set WORK.DEMO.
NOTE: PROCEDURE MEANS used:
    real time     0.25 seconds
    cpu time     0.03 seconds
33 PROC FREQ DATA=demo; TABLES gender;
34 RUN;
NOTE: There were 12 observations read from the data set WORK.DEMO.
NOTE: PROCEDURE FREQ used:
    real time     0.15 seconds
    cpu time     0.03 seconds
Subscribe to:
Posts (Atom)