Module 2: Informats and Formats Flashcards

1
Q

Define informats

A

formats in the input statement that are used to read data values from external files into standard SAS values.

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

What are the 3 informats and their general forms?

A

1) Character:$informatw.
2) Numeric:informatw.d
3) Date: informatw.

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

T/F: You put informats before the variable name in the input statement.

A

False: it comes after

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

Fill in the blank.

When specifying a field width(w), you must count ___.

A

any special characters

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

What does the commaw.d and percentw. informat do?

A

1) removes embeded commas and $
2) divides the number followed by the percent sign by 100

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

What does the mmddyyw. and timew.d. informat do?

A

1) reads in dates in form mmddyy or mmddyyyy
2) reads in time data in form hh:mm:ss:ss or hh:mm

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

What does the colon modifier do?

A

When placed in front of an informat, instructs SAS to read until it encounters a delimiter or the end of the data line

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

What are formats?

A

Used to change how values are displayed, but do not change how they are stored.

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

T/F: Format statements can go inside a data or proc step.

A

True: If in data step, format association is permanent. If in a proc step its temporary

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

What does the bestw. format do?

A

SAS chooses he best format for numeric data. Default length is 12.

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

What does the commaw.d, dollarw.d, and percentw.d format do?

A

1) writes numbers with commas
2) writes numbes wih $ infront and commas
3) writes numbers as percentages

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

What does the mmddyyw., timew.d and worddatew. do?

A

1)writes SAS date values as mm/dd/yyyy or mm/dd/yy
2)writes SAS time values as hh:mm:ss.ss
3)writes SAS date values as month-name dd, yyyy

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

Write the general code to enter data directly into SAS.

A

data name;
/input variables informats;
/datalines;
/data;
run;

bold=keywords(not made by you) /=tab over

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

What is the general format for proc imports?

A

proc import datafile=name/path;
/dbms=file type;
/out=dataname;
/replace;
/guessingrows=n rows;
run;

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

What do the proc import options: dbms, out, and replace do?

A

Dbms: specifies type of data to be imported (csv, xlsx, tab, dlm)
Out: specifies name of file
Replace: overwrites an existing SAS dataset with the same name specified in out

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

What do the optional proc import statements do? (getnames, datarow, sheet, range)

A

Getnames: variable names generated from the first row. Default yes.
Datarow: indicates which row SAS begins to read data.
Sheet: specifies which sheet to get data
Range: specifies the uper and lower corner to get data (syntax: range=’sheetname$UL:LR’)

16
Q

What do the infile options: dlm, firstobs, obs, and dsd do?

A

Dlm: specifies the delimiter
firstobs: indicates row that data begins
obs: useful when you want to input only a few observations
dsd: ignores delimiters if they are within quotes

17
Q

What do the infile options: lrecl and truncover do?

A

lrecl: logical record length, use if longer than default 256.
truncover: forces the input statement to stop reading when it gets to the end of a short line.

18
Q

Given the following code, what will the following dataset look like.

data peeps;
input lastname $10. firstname $ height weight;
datalines;
Johnson Joe 72 165
Smith Jane 64 110
Doe John 67 125
Washington George 42 115
;
run;

A

lastname | firstname | height | weight
Johnson Jo |e|72|165
Smith Jane | 64 | 110 | .
Washington | George | 42 | 115

This is because we didn’t add a colon! before last name format ($10.)