Posts

NOTUPPER AND NOTLOWER

  Function:   NOTLOWER Purpose:   To  determine the position of the first character in a string that is not a lowercase letter. If none is found, the function returns a 0.  With the use of an optional parameter, this function can begin searching at any position in the string and can also search from right to left, if desired.                                    Syntax : NOTLOWER(character-value <,start>)      character-value   Is any SAS character value. Start is an optional parameter that specifies the position in  the string to begin search. If it is omitted,the search starts at the beginning of the string. If it is non-zero, the search begins at the position in the string of the absolute value of the number (starting from the left position in the string). If the start value is positive, the search goes from left to right; if the string is negative, the search goes from right to left, starting at the end of the string. If the value of start  is a positive number longer that the

COMPRESS

Function:   COMPRESS

COMPBL(Compress blanks)

Image
  !) Function:   COMPBL Purpose:   To replace all occurrences of two or more blanks with a single blank character.  This is particularly useful for standardizing  addresses and names where  multiple blanks may have been entered. Syntax : COMPBL(character-value)                                 character-value is any SAS character value.             If a length has not been previously assigned, the length of the resulting             variable will be the length of the argument Example: Using the Combl function to convert multiple blanks to single blank. ***Primary function: COMPBL; data squeeze; input # 1 @ 1 Name $20. # 2 @ 1 Address $30. # 3 @ 1 City $15.    @ 20 State $2.    @ 25 Zip $5. ;   Name = compbl(Name);   Address = compbl(Address);   City = compbl(City);   datalines ; Ron Cody 89 Lazy Brook Road Flemington          NJ     08822 Bill Brown 28 Cathy Street North City          NY      11518 ; run ; title 'Listing of Data Set S

UPCASE, LOWCASE & PROPCASE

Image
!) Function:   UPCASE Purpose:   To  change all letters to uppercase.                                                  NOTE: The corresponding fuction LOWCASE changes uppercase to lowcase Syntax : UPCASE(character-value)                                 character-value is any SAS character value.             If a length has not been previously assigned, the length of the resulting             variable will be the length of the argument Example: ***Primary function: UPCASE ***Other function: DIM; data mixed;   length a b c d e $ 1 ;   input a b c d e x y;   datalines ;   M f P p D 1 2   m f m F M 3 4 ; run ;   data upper;   set mixed;   array all_c[*] _character_;   do i = 1 to dim(all_c);     all_c[i] = upcase(all_c[i]);   end ;   drop i; run ; title 'Listing of Data Set UPPER' ; proc print data =upper noobs ; run ; Output Explanation Remember that uppercase and lowercase values are represented by different internal codes, so if

Function :MDY

Image
 For the situations where you  only have month, day , and year values but do not have a SAS Date, the MDY functon can create a SAS date value, given the value for the month, day , and year .Kindly find a detailed example on how this is made possible in SAS Purpose:   To create a SAS Date from the month, day and year. Sytax: MDY(month, day, year)               month is a numeric variable or constant representing the month of the year (a number               from 1 to 12 ).               day   is a numeric variable or constant representing  the day of the month (a number                  from 1 to 31 ).               year  is a numeric variable or constant representing the year. Values of the month, day and time that do not define a valid date result in a missing value and an error message is written  to the SAS log.            Examples For these examples, M = 11 , D = 15 , Y = 2003.   Function                                              Returns          MDY(M,D,Y)                

Function: CALL SORTC

Image
Function That Sorts Character Values       Purpose : To sort the values of its character arguments in ascending order   Syntax : CALL SORTC(<of> Char-1 <, … Char-n>)                        Char-n is a character variable. If you use a variable list in the form                       Var1–Varn, precede the list with the word "of"'.                      Arguments to the CALL SORTC routine cannot be constants. You may use                      array references as arguments to this routine as well (see the following examples):         Examples      For these examples, c1='bad', c2='good', c3=' ', a1='b', a2='B',  a3='a', and a4='A'.      Also, an array is defined as array chars[3] c1-c3          Call Routine                                                       Return                   CALL SORTC(of c1-c3) CALL SORTC(of chars[*]) CALL SORTC(of a1-a4) c1=' ', c2='

Function: Call Sortn

Image
 Function: Call Sortn Purpose: To sort the values of its numeric argument in ascending order. Syntax :  CALL SORTN(<of> Vaar-1 <,  ... Var-n>)               Var-n  is a numeric variable. If you use a variable list in the form VAR1-Varn,                               precede   the list with  the word "of".               Arguments to the CALL SORTN routine cannot be constants. You may use   array                    references as   arguments to this routine as well (see the following examples)    Examples For these examples, x1=8, x2=2, x3=., x4=1, a=9, b=7, c=8. Also, an array is defined as array nums[4] x1-x4;        Call Routine                                          Returns CALL SORTN(of x1-x4)                        x1=., x2=1, x3=2, x4=8 CALL SORTN(of nums[*])                        x1=., x2=1, x3=2, x4=8 CALL SORTN(a,b,c)                                 a=7, b=8, c=9   Program to grade quizzes, dropping the two lowest quiz scores (using CALL