6 Pages

hand4

Course: STAT 5341, Fall 2009
School: Cincinnati
Rating:
 
 
 
 
 

Word Count: 551

Document Preview

PROGRAMMING SAS HANDOUT #4 INFILE and INPUT STATEMENTS The INFILE statement is used when reading in an external file. The FILE statement is used when outputing data to an external file. The INPUT statement is used to tell SAS how to read the data. It can be used with the INFILE statement (in which...

Register Now

Unformatted Document Excerpt

Coursehero >> Ohio >> Cincinnati >> STAT 5341

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
PROGRAMMING SAS HANDOUT #4 INFILE and INPUT STATEMENTS The INFILE statement is used when reading in an external file. The FILE statement is used when outputing data to an external file. The INPUT statement is used to tell SAS how to read the data. It can be used with the INFILE statement (in which case the data is in an ASCI file), or it can be used if the data is in the program (a CARDS statement is then required) Generally SAS reads data in free format, assuming there is at least one space between values. Missing numerical values should be entered as periods (.). Character values have length of the first value or length 8 which ever is greatest. EXAMPLES: --------- INFILE 'A:\ONE.DAT' PAD; PAD is needed if some lines are shorter than others. INFILE 'A:\ONE.DAT' MISSOVER; MISSOVER is needed if there are missing values at the end of a line INFILE 'A:\ONE.DAT' FIRSTOBS=n; Tells SAS to start reading the data at the nth line, eg n=3 INFILE 'A:\ONE.DAT' DLM=','; The DELIMITER statement tells SAS that variables are separated by a comma. INPUT A $ X; This reads in A as a character variable and X as a numerical variable There must be at least one space between the A and X values Each observation needs to be on a new line. INPUT A $ X @@; This does the same as above, except each line can contain more than one observation. INPUT A : COMMA. B: MMDDYY.; Used when data is free formatted with different lengths. INPUT A $ @4 X; This reads A as a character variable, and reads X as a numerical variable starting in column 4. INPUT A $ 1-5 @10 X; This reads A as a character variable in columns 1-5, and X as a numerical starting variable in column 10 INPUT #1 A $ X #2 B $; This indicates the data is on two lines, variables A and X are on line 1, and variable B is on line 2. INPUT A $ X / B $; Same as above. INPUT A $ X; INPUT B $; Same as above INPUT A $ +2 X; This reads A as a character, then moves 2 spaces to right and reads X. LENGTH A $30.; This indicates the variable A is a character variable of length 30. SAS also has lots of formats/informats that are avialable for reading or writing data. FUNCTIONS: ---------- $ indicates a character variable $ & indicates a character variable with blanks, leave two (2) spaces at end : used when data is in free format @10 points to the column to read variable @@ trailing @@ at end on line indicates more than one observation per line #1, #2 indicates data is on more than one line. / indicates new line of input +2 indicates moving the pointer two spaces to right 1-10 indicates the data is i...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Cincinnati - STAT - 5341
SAS PROGRAMMING HANDOUT #5 DATA SET MERGES There are several ways to combine and/or subset data sets. Suppose AA an
Cincinnati - STAT - 5341
SAS PROGRAMMING HANDOUT # 9 This program will use several of the SAS functions and data set optionsthat we learned in previous handouts. It first generates 100 samples
Cincinnati - STAT - 5341
HANDOUT #10 THE OUTPUT DELIVERY SYSTEM The ODS is a new version 8 method for delivering output. We will first run the following program.ODS TRACE ON;DATA ONE; INPUT X Y @
Cincinnati - STAT - 5341
SASPROGRAMMING HANDOUT #11 This handout will illustrate various options of PROC UNIVARIATE, PROC REG. We will use the GNP data set which is in the SASHELP library on ev
Cincinnati - STAT - 5341
SAS PROGRAMMING HANDOUT #12 INSIGHT#1 INSIGHT can be used to enter and analyse data as in a spreadsheet, or it can b
Cincinnati - STAT - 5341
SAS PROGRAMMING HANDOUT #14 This handout will illustrate some of the features of PROC GPLOT and also showhow do to a normal probablity plot.LIBNAME JIM 'A:\STAT534';DATA
Cincinnati - STAT - 5341
SAS PROGRAMMING HANDOUT #18DATA SALES; LENGTH ITEM $12; INPUT NAME $ MONTH WEEKDAY COMPID STATE $ @25 ITEM $ & UNITS RETAIL TOTRET;CARDS;FOSTER 1 2 153 ID SYSTEM
Cincinnati - STAT - 5341
SAS PROGRAMMING HANDOUT # 19 This handout will write two SAS MACROs to do Handout #9.%MACRO SIM1(K=,N=,MU=,STD=,OUT=);DATA SIMULAT; DO I=1 TO &K; DO K=1 TO &N;
Cincinnati - STAT - 5341
SAS PROGRAMMING HANDOUT #21 This handout tries to illustrate various MACRO functions:%LET = assign a value to a macro variable%EVAL = evaluates arithmetic and l
Cincinnati - STAT - 5341
SASPROGRAMMING HANDOUT #22 This MACRO program considers a categorical variable (DISCRETE) and creates dummy variables. This can then be used together with other MACRO's
Cincinnati - STAT - 5341
SAS PROGRAMMING HANDOUT #23 This handout writes a SAS macro to check for linearity in linear regression, (like HANDOUT #11)by creating dummy CATi variables for the percentil
Cincinnati - STAT - 5341
SAS PROGRAMMING HANDOUT #25 PROC IML is a interactive matrix language that contains lots of matrix functions,SAS functions, and various programming statement
Cincinnati - STAT - 5341
SAS PROGRAMMING HANDOUT #31 This program uses the dataset #2 on the web page to draw the map of china. This program uses the dataset #3 on the web page to draw the map
Cincinnati - STAT - 5341
SAS PROGRAMMING HANDOUT #32DATA JIM; INPUT A $ Y X ;CARDS;AA 74.1 63.1BB 58.4 58.3CC 48.6 41.0DD 33.2 39.2;GOPTIO
Cincinnati - STAT - 5341
SAS PROGRAMMINGHANDOUT #33 MULTIPLE PLOTS PER PAGELIBNAME JIM 'A:\STAT534';DATA GNP; SET JIM.GNP;GOPTIONS RESET=ALL DEVICE=WIN;GOPTIONS NODISPLAY; PROC GPLOT GOUT=WORK.G
Cincinnati - STAT - 5341
DATA YANG; DO DOSE=1 TO 5; DO N=1 TO 10; Y=DOSE+RANNOR(0); OUTPUT; END; END;PROC SORT; BY DOSE;PROC MEANS NOPRINT; BY DOSE; VAR Y; OUTPUT OUT=AA MEAN=MEAN LCLM=LCLM UCLM=UCLM;DATA AA1; SET AA; Y=MEAN; A=1;DATA AA2; SET AA; Y=LCLM; A=1;D
Cincinnati - STAT - 721
WINTER QUARTERSTATISTICAL CONSULTING LAB15-MATH-721-001INSTRUCTOR: JAMES A. DEDDENS Phone: 556-4081OFFICE: 810E Old ChemWEB PAGE: math.uc.edu/~deddensEMAIL: james.deddens@math.uc.edu j
Cincinnati - STAT - 721
STATISTICAL CONSULTING LOGISITIC REGRESSION HANDOUT #2*the data is DATA1 on the web page;DATA ONE; INFILE
Cincinnati - STAT - 721
STATISTICAL CONSULTING LOGISITIC REGRESSION HANDOUT #3*the data is DATA1 on the web page;DATA ONE; INFILE
Cincinnati - STAT - 721
HOMEWORK #4 Consider the SUPPORT data set given as an EXCEL file. See the web-page: http:/hesweb1.med.virginia.edu/biostat/s/data/index.htmlwhere the data set is described and given as a s-plus data set. Using hospita
Cincinnati - STAT - 572
SURVIVAL ANALYSIS15-MATH-572-001SPRING QUARTERINSTRUCTOR: JAMES A. DEDDENS PHONE: 556-4081 OFFICE: 810E OLD CHEM WEB PAGE: math.uc.edu/~deddensTIME: MWF, 12-1 pmCREDITS: 3 HOURS
Cincinnati - STAT - 572
SURVIVAL ANALYSIS HANDOUT #7DATA ONE; INFILE 'C:\JIMSAS\DATA1.TXT'; INPUT ID LOW AGE LWT RACE SMOKE PTL HT UI FTV BWT; IF PTL>=1 THEN PTL=1;PROC LOGISTIC DESCENDING; M
Cincinnati - STAT - 572
SURVIVAL ANALYSIS HANDOUT #11DATA HMOHIV; INFILE 'A:\DATA4.TXT'; INPUT ID @13 ENTDATE DATE7. @23 ENDDATE DATE7. TIME AGE DRUG CENSOR; MONTH=(ENDDATE-ENTDATE)/30;DATA
Cincinnati - STAT - 572
SURVIVAL ANALYSIS HANDOUT #14DATA HMOHIV; INFILE 'A:\DATA4.TXT'; INPUT ID @13 ENTDATE DATE7. @23 ENDDATE DATE7. TIME AGE DRUG CENSOR; MONTH=(ENDDATE-ENTDATE)/30; IF
Cincinnati - STAT - 572
SURVIVAL ANALYSIS HANDOUT #21DATA HMOHIV; INFILE 'A:\DATA4.TXT' pad missover; INPUT ID @13 ENTDATE DATE7. @23 ENDDATE DATE7. TIME AGE DRUG CENSOR; MONTH=(ENDDATE-ENTD
Cincinnati - STAT - 572
SURVIVAL ANALYSIS HANDOUT #22DATA HMOHIV; INFILE 'A:\DATA4.TXT' pad missover; INPUT ID @13 ENTDATE DATE7. @23 ENDDATE DATE7. TIME AGE DRUG CENSOR; MONTH=(ENDDATE-ENTDATE)/30; IF
Cincinnati - STAT - 572
SURVIVAL ANALYSIS HANDOUT #23DATA HMOHIV; INFILE 'A:\DATA4.TXT'; INPUT ID @13 ENTDATE DATE7. @23 ENDDATE DATE7. TIME AGE DRUG CENSOR; MONTH=(ENDDATE-ENTDATE)/30;DATA
Cincinnati - STAT - 572
SURVIVAL ANALYSIS HANDOUT #24DATA HMOHIV; INFILE 'A:\DATA4.TXT' pad missover; INPUT ID @13 ENTDATE DATE7. @23 ENDDATE DATE7. TIME AGE DRUG CENSOR; MONTH=(ENDDATE-ENTDAT
Cincinnati - STAT - 572
SURVIVAL ANALYSIS HANDOUT #28* Data described in Ch. 5 of P. Allison, "Survival Analysis Using the SAS System: A Practical Guide." ;* Stanford heart transplant data;dat
Cincinnati - STAT - 721
FALL QUARTERSTATISTICAL CONSULTING LAB15-MATH-721-001INSTRUCTOR: JAMES A. DEDDENS Phone: 556-4081ROOM: 423C RievschlTIME: MWF 2-3pmOFFICE: 810E Old ChemWEB PAGE: math.uc.edu/~deddensE
Cincinnati - STAT - 721
CONSULTING HANDOUT #3OPTIONS LINESIZE=80;DATA ONE; INPUT ID LOW AGE LWT RACE SMOKE PTL HT UI FTV BWT; IF PTL>=1 THEN PTL=1; CAGE1=(19<AGE<=23); CAGE2=(23<AGE<=26);
Cincinnati - STAT - 721
%MACRO RCSPLINE(x,knot1,knot2,knot3,knot4,knot5,knot6,knot7,knot8,knot9,knot10, norm=2); %LOCAL j v7 k tk tk1 t k1 k2; %LET v7=&x; %IF %LENGTH(&v7)=8 %THEN %LET v7=%SUBSTR(&v7,1,7); %*Get no. knots, last knot, next to last knot;
Cincinnati - STAT - 149
ELEMENTARY PROBABILITY AND STATISTICS15-025-149SUMMER 2004THIRD TERM August 9 to August 28,2004INSTRUCTOR: JAMES A. DEDDENS PHONE: 556-4081 OFFICE: 810E OLD CHEM WEB PA
Cincinnati - STAT - 149
HOMEWORK PROBLEMS FOR PRACTICE EXERCISE NUMBERSCHAPTER 7.1 3,5,9B,13,33,37CHAPTER 7.2 53,58,70,71,74CHAPTER 8.1 1,3,7,16,17,23,24CHAPTER 8.2 31,35,37,39,40,41,45CHAPTER 9.1 1,2,3,11CHAPTER 9
Cincinnati - STAT - 534
SAS PROGRAMMING15-025-534SUMMER QUARTER 2nd HALF TERM July 28- September 2,2004INSTRUCTOR: JAMES A. DEDDENS PHONE: 556-4081 OFFICE: 810E OLD CHEM OFFICE HOURS: 9:30-10 MTWHF
Cincinnati - STAT - 534
HANDOUT #7 THE OUTPUT DELIVERY SYSTEM The ODS is a new version 8 method for delivering output. It allows one to create SAS data sets out of every piece in the output window.
Cincinnati - STAT - 534
SAS PROGRAMMING HANDOUT #26 This handout does some maps of the USA. data salesmap; length stname $20.; input @11 stcode $2. state 3. sales 3. stname $ &;
Cincinnati - STAT - 363
PROB & STAT III HOMEWORK #2 DUE Monday Friday Apr 18 If your UC M-number ends is 0,1,2,3,4 do #12 on page 454 If your UC M-number ends is 5,6,7,8,9 do #13 on page 455 YOU WI
Cincinnati - STAT - 363
PROB & STAT III HOMEWORK #3 DUE Wednesday May 2 If your UC M-number ends is 0,1,2,3,4 do #12 on page 454 If your UC M-number ends is 5,6,7,8,9 do #13 on page 455 THESE ARE TH
Cincinnati - STAT - 363
PROB & STAT III HOMEWORK #5PART 1 Due Wednesday May 28 Using the data from homework #4 find k-1 orthogonal contrasts Compute SSw and perform the test H0: Contrast =0 Try to find one co
Cincinnati - STAT - 363
X1 X2 X3 X4 X5 Y1.31 1.07 0.44 0.75 0.35 1.951.55 1.49 0.53 0.90 0.47 2.900.99 0.84 0.34 0.57 0.32 0.720.99 0.83 0.34 0.54 0.27 0.811.05 0.90 0.36 0.6
Cincinnati - STAT - 363
SYSTEM B1 A1 A2 A3B2 34.00 32.70 32.00 33.20 28.40 29.30 30.10 32.80 30.20 29.80 27.30 28.90B3 29.80 26.70 28.70 28.10 29.70 27.30B4 29.00 28.90 27.60 27.80 28.80 29.10Anova: Two-Factor With Replication SUMMARYB1A1B2 2 66.7 33.35 0.84 2 65
Cincinnati - STAT - 363
Additive Temp Adhesiveness0 50 2.30 50 2.90 50 3.10 50 3.20 60 3.40 60 3.70 60 3.60 60 3.20 70 3.80 70 3.90 70
Cincinnati - STAT - 571
TIME SERIES15-MATH-571-001FALL QUARTERINSTRUCTOR: JAMES A. DEDDENS PHONE: 556-4081 OFFICE: 811d OLD CHEM WEB PAGE: math.uc.edu/~deddensTIME: M
Cincinnati - STAT - 571
DATA SUNSPOT; INPUT NUMB @; N=_N_;CARDS;101 82 66 35 31 7 20 92 154 125 85 68 38 23 10 24 83 132 131118 90 67 60 47 41 21 16 6 4 7 14 34 45 43 48 42 28 10 8 2 01 5 12 14 35 46 41 30 24 16 7 4 2 8 17 36 50 62 67 71 48 288 13 57 122 138 103 86
Cincinnati - STAT - 571
DATA ONE; Z1=0; Z2=0; Z3=0; A1=0; DO N=1 TO 300; A1=RANNOR(123456789); Z1=1.7*Z2-.7*Z3+A1; Z3=Z2; Z2=Z1; OUTPUT; END;PROC ARIMA; IDENTIFY VAR=Z1 STATIONARITY=(ADF);PROC ARIMA; IDENTIFY VAR=Z1(1) STATIONARITY=(ADF); ESTIMATE P=1 NOINT M
Cincinnati - STAT - 571
DATA SUNSPOT; INPUT NUMB @; N=_N_;CARDS;101 82 66 35 31 7 20 92 154 125 85 68 38 23 10 24 83 132 131118 90 67 60 47 41 21 16 6 4 7 14 34 45 43 48 42 28 10 8 2 01 5 12 14 35 46 41 30 24 16 7 4 2 8 17 36 50 62 67 71 48 288 13 57 122 138 103 86
Cincinnati - STAT - 571
DATA AIRLINE; INPUT Y @; YEAR=INT(_N_-1)/12); MONTH=_N_-12*YEAR; DATE=MDY(MONTH,1,YEAR+60); LY=LOG(Y);CARDS;112 118 132 129 121 135 148 148 136 119 104 118115 126 141 135 125 149 170 170 158 133 114 140145 150 178 1
Cincinnati - STAT - 571
DATA SUNSPOT; INPUT NUMB @; N=_N_;CARDS;101 82 66 35 31 7 20 92 154 125 85 68 38 23 10 24 83 132 131118 90 67 60 47 41 21 16 6 4 7 14 34 45 43 48 42 28 10 8 2 01 5 12 14 35 46 41 30 24 16 7 4 2 8 17 36 50 62 67 71 48 288 13 57 122 138 103 86
Cincinnati - STAT - 571
DATA AIRLINE; INPUT Y @; NN=_N_;CARDS;112 118 132 129 121 135 148 148 136 119 104 118115 126 141 135 125 149 170 170 158 133 114 140145 150 178 163 172 178 199 199 184 162 146 166171 180 193 181 183 218
Cincinnati - STAT - 571
title1 h=2 f=swiss 'Intervention Data for Ozone Concentration';title2 h=2 f=swiss 'Box and Tiao, JASA 1975 P.70';data air; input ozone @; label ozone='Ozone Concentration' x1='Intervention' summer='Summer Months Intervention
Cincinnati - STAT - 534
SAS PROGRAMMING HANDOUT #4 INFILE and INPUT STATEMENTS The INFILE statement is used when reading in an external file. The FILE statement is us
Cincinnati - STAT - 534
SAS PROGRAMMING HANDOUT #6 SAS FUNCTIONS SAS allows many functions to be used in the data step, for example:+,-,/,*
Cincinnati - STAT - 534
HANDOUT #7 THE OUTPUT DELIVERY SYSTEM The ODS is a new version 8 method for delivering output. It allows one to create SAS data sets out of every piece in the output window.
Cincinnati - STAT - 534
SAS PROGRAMMING HANDOUT #9 SOME COMPLEX INPUT STATEMENTS There are several different DO loops possible in the SAS data step.
Cincinnati - STAT - 534
SASPROGRAMMING HANDOUT #11 This handout will illustrate various options of PROC UNIVARIATE, PROC REG. We will use the GNP data set which is in the SASHELP library on e
Cincinnati - STAT - 534
SAS PROGRAMMING HANDOUT #14 This handout will illustrate some of the features of PROC GPLOT and also showhow do to a normal probablity plot.LIBNAME JIM 'A:\STAT534';DATA
Cincinnati - STAT - 534
SAS PROGRAMMING HANDOUT # 19 This handout will write two SAS MACROs to do Handout #10.%MACRO SIM1(K=,N=,MU=,STD=,OUT=);DATA SIMULAT; DO I=1 TO &K; DO K=1 TO &N;
Cincinnati - STAT - 534
SAS PROGRAMMING HANDOUT #24 This handout uses PROC IML to diagonize a symmetric matrix:PROC IML; A={1 2 3,4 5 6,5 7 9}; * this inputs a
Cincinnati - STAT - 534
SAS PROGRAMMING HANDOUT #31 This program uses the dataset #2 on the web page to draw the map of china. This program uses the dataset #3 on the web page to draw the map
Cincinnati - STAT - 534
SAS PROGRAMMING HANDOUT #34DATA YANG; DO DOSE=1 TO 5; DO N=1 TO 10; Y=DOSE+RANNOR(0); OUTPUT; END; END;PROC SORT; BY DOSE;PROC MEANS NOPRINT; BY DOSE; VAR Y; OUTPUT O