Module 3: Creating and Managing Variables Flashcards
What format does SAS spit out for the following date formats: mmddyy10., mmddyy8., date9., and date7.?
Ex. mmddyy, mmddyyyy, Oct. _th
1) mmddyy10.=mm/dd/yyyy
2) mmddyy8.=mm/dd/yy
3) date9.=ddOctyyyy
4) date7.=ddOctyy
What format does SAS spit out for the following date formats: julian7., worddate18., and weekdate29. ?
1)julian7.=yyyyjulian
2)worddate18.=month d, yyyy
3)weekdate29. weekday month d, yyyy
T/F: You can manipulate dates with numeric symbols.
Ex. +, - , /, etc.
True: but only if it’s in numeric character format
List some common and simple date functions
Ex. day()
1) day()
2) month()
3) year()
4) qtr()
5) weekday()
6) mdy(month,day,year)
Why is the intnx() function useful and write general syntax.
It is used to help with incrementing dates.
var=intnx(‘incre’, varname, -1,1,0, daytoincrement)
daytoincrement= first day(1), end of month(‘E’) etc
What format does SAS spit out for the following date formats: time8. and time12.?
1)time8.=hh:mm:ss
2)hh:mm:ss.ss
What are the parameters for the dhms() function?
Ex. what’s inside the (x,y,x)
(day,hour,minutes, seconds)
T/F: You can treat datetime functions like date values to do mathematical calculations.
False: You need to treat them as time values
What does the ceilings and floor functions do?
1)ceil(): returns the smallest integer that is greater than or equal to the argument
2) floor(): returns the largest integer that is less than or equal to the argument
What does the int function do?
int() returns the integer protion of a numeric value
Write the syntax for round() for an integer number and for a decimal.
1) var=round(var,1)
2) var=round(var,0.01)
Write the syntax for scan() and explain what it does.
scan(string,n,delimiter)
returns the nth word from a string/variable
Note: you can omitt the delimier and SAS assumes all can be delimiters
What is the syntax for substr() and what does it do?
substr(string, position, n)
It extracts from a string starting from the postion to n length
What does the length() function do?
Gives the length of a string, excluding trailing and leading blanks
What does the trim(), strip(), left() and right() functions do?
1) trim() removes trailing blanks
2) strip() removes trailing leading blanks
3)left() moves blanks to be trailing
4)right() moves blanks to be leading
What is the difference between cat(), cats(), and catx()?
1) cat() concats 2+ variables, leaving in trailing and leading blanks
2) cats() concats 2+ variables, removing blanks
3) catx() concats 2+, removing blanks, and puts in seperators
syntax: catx(seperator,var)
What are the three functions to transform uppercase, lowercase, and propercase
upcase()
lowcase()
propcase()
What does the index and find functions do?
1)index():searches for the first occurance and returns the postion of the first character
2)find(): same as index, but accepts third argument to indicate which column to start the search
What does the tranwrd function do?
replaces or removes all occurances of a word in the character string
tranwrd(var,target, replacement)
What does the compress function do?
removes all instances of specified characters
What does the input() and put() functions do?
1) input() converts variables from character to numeric variables
2) put() converts variables from numeric to character variables