Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

SAS Data Analysis: Troubleshooting & Descriptive Stats from Data Sets, Lab Reports of Psychology

An overview of how to get data into sas using the cards or datalines statement, troubleshoot common issues such as incorrect data set names, and obtain descriptive statistics using the proc means procedure. It covers both temporary and permanent data sets, with examples using the sas editor and the point and click method.

Typology: Lab Reports

Pre 2010

Uploaded on 09/02/2009

koofers-user-jt9
koofers-user-jt9 🇺🇸

10 documents

1 / 6

Toggle sidebar

Related documents


Partial preview of the text

Download SAS Data Analysis: Troubleshooting & Descriptive Stats from Data Sets and more Lab Reports Psychology in PDF only on Docsity! Troubleshooting and Finding Descriptive Statistics 1 Cards or Datalines During the last lab we explored how to get data set into SAS using external files. The other way of getting data into SAS is using a cards or datalines statement. For example; data c; input race sex hair $; cards; 4 1 black 2 1 brown 3 0 blonde 3 1 brown 2 1 brown 1 0 black 4 1 brown 4 1 brown 1 0 blonde 2 0 black 3 1 black 4 0 brown 3 1 black 6 0 brown ; proc print data=c; run; proc freq; tables hair; run; 2 Troubleshooting 2.1 Correctly Identifying You Data Problem: Trying to use a proc on a data set that does not exist. For example: data b; input sex height; cards; 1 72 0 70 1 69 0 62 0 59 1 0 67 1 70 1 69 ; proc means data=lab1; var height; run; Notice that the data name used in the proc means statement does not match the name of the data set created. This code will result in the data set ’b’ being entered, but no proc means statement will be done. So, either make sure that your data= is correct or don’t put it there at all. For example notice in the following that there is no data= statements. OPTIONS LS=80 NOCENTER pagno=1; DATA ONE ; array lamda (2, 6) lamda11-lamda16 lamda21-lamda26; input ITER NOBS lamda11-lamda16 lamda21-lamda26 ; CARDS; 1 20 .1 .2 .4 .8 .8 .8 .15 .3 .6 1.2 1.2 1.2 ; DATA TWO; SET ONE; array lamda (2, 6) lamda11-lamda16 lamda21-lamda26; seed1=136121; * you can change this to get a different set of data; do i=1 to nobs; do J=1 to 2; do k=1 to 6; Y1=-LOG(ranuni(seed1))/LAMDA{j,k}*abs(J-2)+(J-1)* sqrt(-LOG(ranuni(seed1))/LAMDA(j,k)) ; DEATH1=0; C1=1000; IF C1 GT Y1 THEN DEATH1=1; T11=DEATH1*Y1+(1-DEATH1)*C1; agecat=j; dose =k; hazard=LAMDA{j,k}*abs(J-2)+(J-1)* LAMDA{j,k}*2*t11; OUTPUT; end; END; end; run; data three; set two ; if dose ge 5 and agecat=2 then dose=4; if dose gt 4 then delete; agecat=agecat-1; * this is just to make agecat 0,1 instead of 1,2; agitates=agecat*dose; dlogist=0; 2 FREQ variables; OUTPUT OUT=SASdataset keyword=names ...; There are many keywords that can go in the ’option(s)’ portion, they range from fixing the number of decimal points used, to setting the alpha on a t-test. The different sta- tistical keywords that can be used are: CLM, RANGE, CSS, SKEWNESS—SKEW, CV, STDDEV—STD, KURTOSIS—KURT, STDERR, LCLM, SUM, MAX, SUMWGT, MEAN, UCLM, MIN, USS, N, VAR, NMISS, MEDIAN—P50, Q3—P75, P1, P90, P5, P95, P10, P99, Q1—P25, QRANGE, PROBT and T. There is not much difference in the BY and CLASS statements. The main difference being that when CLASS is used the variables do not have to be sorted. For this reason I recommend using CLASS. 3.2 Permanent Files 3.2.1 Using the Editor For some review permanent SAS files are created by the following code: proc import datafile=P:\mclainexcel.xls out=excel replace; getnames=yes; run; libname abc P:\; data abc.perm; set excel; run; Which will create a permanent SAS file in your P directory from the excel file ’mclainexcel’. After the permanent SAS file is created it can be recalled using the following: libname usc P:\; proc print data=usc.perm; run; proc means data=usc.perm; var Height; run; Another way to load a permanent SAS file is by double clicking on the file, try this on the permanent SAS file in Blackboard. Once in SAS notice the name of the SAS file in the upper left corner, this will be the name you will use execute a proc. In this next example ’Hanes’ has been double clicked and the name TMP1.hanes has been assigned to it. Now proc means can be used on the variable ’sysbp’ which is the variable name for ’Average Systolic BP’ using the following: proc means data=tmp1.hanes; var sysbp; run; 5 3.2.2 Using the Point and Click While in the Editor Window click the pull down menu ’Solutions’, then click the first option ’Analysis’, and finally choose the ’Analyst’ option. This should bring you to a window with a spreadsheet. Now load in your permanent SAS using the File pull down menu and Open. Now find you permanent SAS file in the directory, click on it, and select open. Most of the descriptive statistics in proc means will be under Statistics→Descriptive→Summary Statistics. 6
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved