Module 2: Informats and Formats Flashcards
Define informats
formats in the input statement that are used to read data values from external files into standard SAS values.
What are the 3 informats and their general forms?
1) Character:$informatw.
2) Numeric:informatw.d
3) Date: informatw.
T/F: You put informats before the variable name in the input statement.
False: it comes after
Fill in the blank.
When specifying a field width(w), you must count ___.
any special characters
What does the commaw.d and percentw. informat do?
1) removes embeded commas and $
2) divides the number followed by the percent sign by 100
What does the mmddyyw. and timew.d. informat do?
1) reads in dates in form mmddyy or mmddyyyy
2) reads in time data in form hh:mm:ss:ss or hh:mm
What does the colon modifier do?
When placed in front of an informat, instructs SAS to read until it encounters a delimiter or the end of the data line
What are formats?
Used to change how values are displayed, but do not change how they are stored.
T/F: Format statements can go inside a data or proc step.
True: If in data step, format association is permanent. If in a proc step its temporary
What does the bestw. format do?
SAS chooses he best format for numeric data. Default length is 12.
What does the commaw.d, dollarw.d, and percentw.d format do?
1) writes numbers with commas
2) writes numbes wih $ infront and commas
3) writes numbers as percentages
What does the mmddyyw., timew.d and worddatew. do?
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
Write the general code to enter data directly into SAS.
data name;
/input variables informats;
/datalines;
/data;
run;
bold=keywords(not made by you) /=tab over
What is the general format for proc imports?
proc import datafile=name/path;
/dbms=file type;
/out=dataname;
/replace;
/guessingrows=n rows;
run;
What do the proc import options: dbms, out, and replace do?
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