Module 3: Creating and Managing Variables Flashcards

1
Q

What format does SAS spit out for the following date formats: mmddyy10., mmddyy8., date9., and date7.?

Ex. mmddyy, mmddyyyy, Oct. _th

A

1) mmddyy10.=mm/dd/yyyy
2) mmddyy8.=mm/dd/yy
3) date9.=ddOctyyyy
4) date7.=ddOctyy

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What format does SAS spit out for the following date formats: julian7., worddate18., and weekdate29. ?

A

1)julian7.=yyyyjulian
2)worddate18.=month d, yyyy
3)weekdate29. weekday month d, yyyy

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

T/F: You can manipulate dates with numeric symbols.

Ex. +, - , /, etc.

A

True: but only if it’s in numeric character format

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

List some common and simple date functions

Ex. day()

A

1) day()
2) month()
3) year()
4) qtr()
5) weekday()
6) mdy(month,day,year)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Why is the intnx() function useful and write general syntax.

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What format does SAS spit out for the following date formats: time8. and time12.?

A

1)time8.=hh:mm:ss
2)hh:mm:ss.ss

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the parameters for the dhms() function?

Ex. what’s inside the (x,y,x)

A

(day,hour,minutes, seconds)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

T/F: You can treat datetime functions like date values to do mathematical calculations.

A

False: You need to treat them as time values

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does the ceilings and floor functions do?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does the int function do?

A

int() returns the integer protion of a numeric value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Write the syntax for round() for an integer number and for a decimal.

A

1) var=round(var,1)
2) var=round(var,0.01)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Write the syntax for scan() and explain what it does.

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the syntax for substr() and what does it do?

A

substr(string, position, n)
It extracts from a string starting from the postion to n length

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What does the length() function do?

A

Gives the length of a string, excluding trailing and leading blanks

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does the trim(), strip(), left() and right() functions do?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the difference between cat(), cats(), and catx()?

A

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)

17
Q

What are the three functions to transform uppercase, lowercase, and propercase

A

upcase()
lowcase()
propcase()

18
Q

What does the index and find functions do?

A

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

19
Q

What does the tranwrd function do?

A

replaces or removes all occurances of a word in the character string
tranwrd(var,target, replacement)

20
Q

What does the compress function do?

A

removes all instances of specified characters

21
Q

What does the input() and put() functions do?

A

1) input() converts variables from character to numeric variables
2) put() converts variables from numeric to character variables