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