Posts

INDEX TO SAS TUTORIALS

Index to Statistics Tutorials PROC MEANS Tutorial (Descriptive statistics) PROC UNIVARIATE Tutorial (Distribution analysis) New: PROC UNIVARIATE - Advanced Tutorial PROC CORR Tutorial (Correlation) PROC FREQ Tutorial 1 (Frequency Tables/Goodness of Fit) PROC FREQ Tutorial 2 (Two-way tables) PROC TTEST Tutorial (Two sample and paired t-tests) New: A comparison of Paired & Independent Sample t-test s PROC ANOVA & GLM Tutorial (One-Way ANOVA) PROC GLM Tutorial (Repeated measures ANOVA using PROC GLM) New: Survival Analysis & comparison of groups using PROC LIFEREG Bland-Altman Analysis (Comparing two measures) Inter-Rater Reliability, Kappa, Weighted Kappa (PROC FREQ) New: SAS Functions (2-part tutorial) Special SAS Topics New: Read and Write SAS Data Sets the EASY way Setting the SAS Initial Folder (default directory) Using SAS ODS Output, Styles, Graphics, Data Data files and SAS code for tutorials

FIRST. and LAST. variables: Data step processing within by groups using the SET statement

FIRST. and LAST. variables: Data step processing within by groups If you use a by statement along with a set statement in a data step then SAS creates two automatic variables, FIRST.variable and LAST.variable, where variable is the name of the by variable. FIRST.variable has a value 1 for the first observation in the by group and 0 for all other observations in the by group. LAST.variable has a value 1 for the last observation in the by group and 0 for all other observations in the by group. The code shown below is available here . data temp; input group x; cards; 1 23 1 34 1 . 1 45 2 78 2 92 2 45 2 89 2 34 2 76 3 31 4 23 4 12 ; run; /************************************************** The automatic variables first.group and last.group are not saved with the data set. Here we write them to data set variables to show their contents. **************************************************/ data new; set temp; by group; first=first.group; last=last.group; run; proc print; title 'Raw data al...

How to determine the last observation in a data set

Determine the last observation in a data set Use the END= option on a SET statement to determine the last observation of the data set. /* Create sample data */ data company; input division :$12. employees; datalines; sales 150 support 200 research 250 accounting 50 shipping 35 ; run; /* Calculate the total number of employees in each group. */ /* On the last observation of the data set, write out the */ /* resulting total. */ data _null_; set company end=last; file print; /* Sum statement syntax has an implied RETAIN */ total + employees; /* For every iteration of the step, write out the values for */ /* DIVISION and EMPLOYEES. */ put @1 division @15 employees; /* On the last iteration of the step only, write out 4 dashes */ /* starting at column 15, move the internal pointer to the next */ /* line and at column 15 write out the value of TOTAL. */ if last then put @15 '----' / @15 total; run; RESULT: sales 150 support 200 research 250 accounting 50 shipping 35 ---- source: http...

SAS Clinical Interview QUESTIONS and ANSWERS

SAS Clinical Interview Questions and Answers SAS Clinical Interview Questions and Answers Here is a list of common SAS clinical interview questions along with example answers and explanations to help you prepare for your next interview. 1. What is SAS? SAS stands for Statistical Analysis System. It is a software suite used for advanced analytics, business intelligence, data management, and predictive analytics. It is widely used in clinical trials for analyzing clinical data. 2. What are the phases of clinical trials? The phases of clinical trials include: Phase I: Tests safety and dosage with a small group of healthy volunteers. Phase II: Tests efficacy and side effects with a larger group of patients. Phase III: Confirms effectiveness, monitors side effects, and compares with other treatments in larger patient groups. Phase IV: Conducts post-marketing studies to gather additional inf...

How to determine whether a numeric or character value exists within a group of variables

Using the IN operator to determine whether a numeric or character value exists within a group of variables When trying to determine whether a specific value exists within a group of variables, a common approach is to associate the variables with an ARRAY and then use a DO loop to loop through every element or variable in the ARRAY. As an example, here is a segment of code: array my_array[*] var1 - var10; do i = 1 to dim (my_array); if some_value = my_array[ i ] then found = 'Yes' ; end ; A more efficient alternative is to use the IN operator with the name of the ARRAY and avoid using the DO loop. This can be done with both numeric ARRAYS as well as character ARRAYS. Here is a code segment: array my_array[*] var1 - var10; if some_value IN my_array then found = ' Yes '; source: http://support.sas.com/kb/33/227.html

How to convert a SAS date to a character variable

/***************************************************************************//* Title: Convert a SAS date to a character variable *// * *//* Goal: Use the PUT function to create a character variable from *//* a SAS date. *//* *//***************************************************************************/ data one; input sasdate :mmddyy6.; datalines; 010199; run; data two; set one; chardate=put(sasdate,mmddyy6.); run; /* RESULTS */ Obs sasdate chardate 1 14245 010199 Source: ftp://ftp.sas.com/techsup/download/sample/datastep/convertchar.html

How to convert a character variable that represents a date into a SAS date

Convert a character variable that represents a date into a SAS date Use the INPUT function to convert a character value that represents a date into a SAS date value. Data one; input chardate1 :$6. chardate2 :$9. chardate3 $10. chardate4 :$9.; datalines; 010199 31dec1999 21/09/2005 5/9/2005; Run; /* Use the INPUT function to convert a character value that represents a date *//* into a SAS date value. Choose the second parameter to the INPUT function *//* based upon what the current character value looks like. Use a FORMAT *//* statement to apply the date format you want when you are done. *//* *//* Note: If you are in SAS 9.0 or above, you may prefer using the ANYDTDTEw. *//* Informat as the second argument to the INPUT function. ANYDTDTEw. *//* can read multiple date layouts. Refer to the SAS Language Reference, *//* Dictionary under INFORMATS for more information. */ data two; set one; sasdate1=input(chardate1,mmddyy6.); sasdate2=input(chardate2,date9.); sasdate3=input(chardate3,ddmmy...