- Shuffle
Toggle OnToggle Off
- Alphabetize
Toggle OnToggle Off
- Front First
Toggle OnToggle Off
- Both Sides
Toggle OnToggle Off
Front
How to study your flashcards.
Right/Left arrow keys: Navigate between flashcards.right arrow keyleft arrow key
Up/Down arrow keys: Flip the card between the front and back.down keyup key
H key: Show hint (3rd side).h key
![]()
PLAY BUTTON
![]()
PLAY BUTTON
![]()
196 Cards in this Set
- Front
- Back
|
SAS dataset names can be how long and contain what?
|
1-32 characters long, can contain letters in upper or lower can, underscores ( _ ) and numbers
|
|
True or False. numbers can’t start a dataset name
|
True
|
|
SAS data has 2 parts. What are they?
|
a descriptor portion and a data portion
|
|
What does a Descriptor portion contain?
|
name of the dataset, date and time the dataset was created, number of observations, number of variables
|
|
What does the Data portion contain?
|
observations (rows), variables (columns), contains missing values (“” or ., for characters and numeric respectively)
|
|
What do Variable attributes contain?
|
name (which follows the same rules as dataset names), type (either character or numeric), length (characters up to 32767 bytes long and numeric are all length 8)
|
|
What are additional characteristics of a Variable?
|
Additionally variables can have a format (which specifies the way the data is written and its width and the number of decimal points if numeric), an informat (which transforms variables written in a specific format to remover characters [$, , ] from numeric variables) and a label (which is descriptive text to describe the variable up to 256 characters)
|
|
The Output window can show two different kinds of output. What are they?
|
listing (the traditional output) and HTML
|
|
Name 3 libraries for the user defined by SAS
|
Sashelp, Sasuser, Work
|
|
What statement is used to define a library?
|
use the libname statement with a name for the library (1-8 characters long and following dataset name rules) and a file location
|
|
The Programming Workspace consists of what?
|
the Explorer, Log, Output, Results and editing windows (i.e., the Enhanced Editor and Program Editor )
|
|
What procedure is used to view the contents of a library?
|
Proc Contents data=filename nods
run; |
|
In PROC CONTENTS what suppresses data on each dataset in the library?
|
nods
|
|
What PROC step overlaps with PROC CONTENTS?
|
Proc Datasets can also be used and overlaps in most functionality.
Proc Datasets <options>; Contents <options>; quit; It can can only reference the library stipulated in its data=option |
|
What can be used to view variables in their logical progression in the data?
|
VARNUM. For example,
proc contents data=dsname order=varnum; run; |
|
How can SAS output be controlled?
|
Using an Options statement
For example: options pagesize=60; |
|
What SAS output can be controlled?
|
line size, page size, display of page numbers, display of date and time
For example: options pagesize=60 linesize=80 pageno=1 nodate nocenter; |
|
What option shows the date and time of the output creation?
|
Date/nodate
|
|
What option displays the page number or not?
|
Number/nonumber
|
|
What option tells the program to begin page numbers at a specific number (and is 1 by default)?
|
Pageno
|
|
What option tells the program the number of lines to display in the output (and includes all date, time and variable name lines)?
|
Pagesize
For example: options pagesize=60; The options statement should NOT appear inside a data step or a proc step The pagesize option (synonym ps) sets the number of lines per page in the SAS output window |
|
What option specifies the width of the print line and observations that don’t fit are continued on the following line?
|
Linesize
The linesize option is used in either the infile statement or in the options statement. Used in the infile statement, the linesize option sets the length of the line read from a data file. Default is 80 Used in the options statement, the linesize option sets the width of lines written to the output window |
|
What option tells SAS which year to start with for a two-digit year counting system and covers a 100 year span?
|
Yearcutoff
|
|
What option specifies which observation SAS will start to display ?
|
Firstobs
|
|
What option tells SAS to stop after a specific observation?
|
Obs
|
|
What option specifies the character formatting in the output tables and dividers?
|
Formchar
|
|
What option specifies the delimit character for page breaks, normally set to null?
|
Formdlim
|
|
What option replaces variable names with labels and can only be used in a Data step if first initiated for the system?
|
Label/nolabel
|
|
What option specifies whether or not new permanent datasets replace existing ones, default is noreplace?
|
Replace/noreplace
|
|
What option specifies if SAS statements are written to the Log
|
Source/nosource
|
|
Is the following example of the DATA Step Debugger correct?:
Data perm.publish / debug; Infile pubdata; Run; |
Yes
|
|
Which of these is NOT true about:
libname esdb 's:\esdb_final\datasets'; PROC PRINT data= esdb.herdata; Run; 1.all observations and variables are printed 2.you DO NOT get, by default, an OBS column 3.columns appear in order they occur in the data set 4.an = sign is required, as in data= |
#2
|
|
For the following code, which is FALSE:
PROC PRINT data= esdb.herdata NOOBS; VAR cocode sscode ; Run; 1. You can select which columns get printed 2. You can NOT select the order columns are printed 3. To remove OBS column, specify the NOOBS option |
#2
|
|
What statement is used to replace the OBS column?
|
ID
|
|
True or False. • If column is specified in ID statement and in VAR statement, the column is printed twice.
|
True
|
|
True or False. You can specify any VARS in the WHERE, EXCEPT those in VAR statement.
|
True
|
|
What's the difference between:
1.where firstname CONTAINS 'Jon'; 2.where firstname ? 'Jon'; |
None.
|
|
What does the CONTAINS operator do?
|
In a where clause, it selects observations that include the specified substring
|
|
Where does [descending] go in the following:
PROC SORT data= <sas dataset set> out= <new dataset>; By VAR(s); run; |
PROC SORT data= <sas dataset set> out= <new dataset>;
By [descending] VAR(s); run; |
|
True or False. You have to name the VARs in a VAR statement if you specify them in the SUM statement
|
False. You do NOT have to name the VARs in a VAR statement if you specify them in the SUM statement. For Example:
PROC PRINT data= help.snacks; VAR Price Advertised Holiday Date Product ; Where QtySOld > 65 and Holiday=1; SUM QtySold; run; |
|
True or False. To request subtotals, use a SUM statement and add a by statement for all numeric columns.
|
True. For example:
PROC PRINT data= snacks; VAR Price Advertised Holiday Date Product; SUM QtySold; by advertised holiday; run; |
|
How can you request subtotals on separate pages?
|
Use PAGEBY. For example:
PROC PRINT data= snacks; VAR Price Advertised Holiday Date Product; where QtySold > 65; SUM QtySold; by advertised holiday; Id advertised holiday; PAGEBY advertised ;/* only works with one VAR */ run; |
|
Using PROC PRINT, how do you make SAS listing output to double space
|
use DOUBLE option. For example:
PROC PRINT data= help.snacks(obs=10) double; VAR QtySold Price Advertised Holiday Date Product; run; |
|
The DOUBLE option works with HTML output
|
FALSE
|
|
How many titles can you associate with the TITLE statement?
|
10
|
|
How many titles can you associate with the FOOTNOTE statement?
|
10
|
|
True or False. TITLE and FOOTNOTE are global statements?
|
True
|
|
How do you modify or cancel TITLE and/or FOOTNOTE?
|
Use a NULL TITLE or FOOTNOTE. For example:
title1 "David's favorite data set”; title3 "Cris is writing another check SAS program!"; PROC PRINT data= esdb.herdata (obs=20) ; VAR COCODE SSCODE Value Year; run; title; |
|
How do you assign a description to a column?
|
Use the LABEL statement.
|
|
What is the difference between a LABEL option and statement?
|
The LABEL option in PROC PRINT specifies that the labels are displayed. For example:
PROC PRINT data= esdb.dotdata(obs=20)label ; Label COCODE= ‘ESDB country code’ SSCODE= ‘ESDB series code’; run; |
|
True or False. The following PROC correctly uses FORMAT:
PROC PRINT data= esdb.dotdata(obs=10) ; format value comma25. ; run; |
True
|
|
True or False. Lables and formats can be permantenly assigned
|
True
|
|
True or False. Once a permanent label has been assigned inside a data step, nothing else is required in the PROC PRINT statement
|
False. you MUST add the label option in the PROC PRINT! For example:
PROC PRINT data= inside_dataset label; run; |
|
What is the purpose of the SPLIT= option in PROC PRINT?
|
Together with a LABEL statement, it tells where the text splits
|
|
True or False. PROC FORMAT can also change the appearance of output
|
True. For Example:
PROC format; value value_fmt 1= 'Free' 2= 'Partly Free' 3= 'Not Free'; |
|
Specify a Comma format
|
COMMAw.d
Example: comma8.2 |
|
Specify a Dollar format
|
DOLLARw.d
Example: dollar6.2 |
|
Specify a MMDDYY format
|
MMDDYYw.
Example: MMDDYY10. |
|
Spedcify a format rounding off to the nearest integer in w spaces
|
w.
Example: 7. |
|
Specify a format rounding off to d decimal places in w spaces
|
w.d
Example: 8.2 |
|
Specify a format as character values in w spaces
|
$w.
Example: $12. |
|
Specify a format as data value in the form 16OCT99 or 16OCT1999
|
DATEw.
Example: date9. |
|
True or False. INFILE and FILE work with files, while INPUT and PUT deal with variables.
|
True
|
|
What are the 2 forms raw data can take?
|
Fixed fields - values for each variable are in the same location in all records.
Column input - specifies actual column location for values |
|
Describe a statement that would be used to read a variable ActLevel (character variable starting in column 9, ending in column 12) and Age (which is numeric in columns 6 through 7)
|
input ActLevel $ 9-12 Age 6-7;
|
|
A SAS Expression is composed of what two things?
|
1.Operand
2.Operator |
|
What is the order of precedence of SAS Arthmetic Operators?
|
1.Highest. negative prefix, exponention
2.Second priority. Multiplication, division 3.Third priority. Addition, substraction |
|
True or False. A Date constant is stored as a character
|
False. Dates are stored as numeric. Without the D, a date would be stored as character, therefore not recognized as a date. e.g., '26oct2010'd
|
|
True or False. INFILE is used to read instream data.
|
False. INFILE is used for reading external files. DATALINES is used to read instream data
|
|
True or False. use File and PUT to reading in data
|
False. Use File and PUT to OUTPUTTING DATA FROM SAS TO EXTERNAL FILES. Use INFILE and INPUT for reading in data
|
|
True or False. YOu can Access an Excel file by treating it as a SAS library
|
True. e.g.,
LIBNAME dtug_xl 'S:\Esdb_Source\Results.xls'; |
|
True or False. You can access an Access Excel data as a data set within that library
|
True. e.g.,
SET dtug_xl.'Ranking_N_10$'n The N tells SAS it's a name. Hence, this is called a SAS name literal. |
|
How do you describe the contents of an entire library use the reserved keyword?
|
To describe the contents of an entire library use the reserved keyword _all_:
PROC CONTENTS DATA=esdb._all_; RUN; |
|
Describe what each option in the following LIBNAME statement does:
LIBNAME dtug_xl 'S:\Esdb_Source\Results.xls' GETNAMES=YES SCANTEXT=YES MIXED=YES; |
GETNAMES-determines whether or not to use the first row of data in Excel as column names
SCANTEXT-specifies whether to read the entier data columnand use the length of the longest string found as the SAS column width MIXED-specifies whether to import data with both character and numeric values and conver everything to character |
|
Name 3 things that happen during the compilation phase
|
1)creation of IB,
2)creation of PDV 3)syntax checking |
|
What happens during the Execution Phase
|
creation of physical SAS dataset (or _NULL_ data set)
|
|
Name two options in the following PROC:
PROC FORMAT <options>; run; |
1. LIBRARY=libref. Use libref to declare a permanent store. LIBRARY can be abbreviated to LIB
2. FMTLIB. Prints contents of a format catalog |
|
What is required if format-name is a character?
VALUE format-name Range1=’label1’ Range2=’label2’ …; |
Place a '$' before format-name.
|
|
In the following, what is the MAX numeric Range in Range1?:
VALUE format-name Range1=’label1’ Range2=’label2’ …; |
range of numeric values, such as 0-1500
|
|
If it's a range of characters, what needs to be done to the following--i.e., format-name AND Range1?:
VALUE format-name Range1=’label1’ Range2=’label2’ …; |
if it's a range of character, then the values must be enclosed in quotes, such as ‘A’-‘M’. If it’s a range of character, the format name must start with a dollar sign ($)
|
|
True or False. YOu can combine character and numerics values in a range, as in Range1?
VALUE format-name Range1=’label1’ Range2=’label2’ …; |
False. You CANNOT be a combination of character and numeric values
|
|
Which is false regarding "format-name" in the following:
VALUE format-name Range1=’label1’ Range2=’label2’ …; 1. must be a valid SAS name 2. cannot be the name of an existing SAS format 3. cannot end in a number 4. does not end in a period when specified in a VALUE statement. |
None. They are all true
|
|
What is true regarding Lables, such as 'label1'?:
VALUE format-name Range1=’label1’ Range2=’label2’ …; 1. Labels need to be enclosed in quotation marks 2. Limit labels to 256 characters 3. Use two single quotation marks if you want an apostrophe to appear in the label |
They are all true.
|
|
Which is searched for first for formats: TEMP Library or PERM Library.
|
TEMP library
|
|
How do you delete formats in SAS?
|
DELETE formats using PROC CATALOG or the SAS Explorer window
|
|
Assume that value_fmt is user-defined. What is wrong with the following?:
DATA perm.frhdata; Infile frhdata; Input @1 cocode $4. +21 value 2.; Format value value_fmt; RUN; |
A period is required after value_fmt. in order to associate the user-defined format with a variable in a FORMAT statement---i.e.,
Format value value_fmt.; |
|
Name 4 commonly used formats and informats.
|
1. $w.
2. w.d 3. COMMAw.d 4. DOLLARw.d |
|
Name 4 common data formats and what they produce
|
1.MMDDYY6.
010160 2.DDMMYY8. 31/12/60 3.DATE9. 31DEC1959 4.WEEKDATE. Friday, January 1, 1960 |
|
In PROC REPORT, which are TRUE:
a) ALL obs and vars in dataset are printed b) Variables appear in order in which they occur in dataset c) CHAR values lef justifed; NUMERIC right justified d) Column headings = var names |
All of the above are TRUE
|
|
How do you filter in PROC REPORT?
|
Use a WHERE clause.
|
|
True or False. PROC REPORT can only use 1 DEFINE statement
|
False. Can use 1 or MORE DEFINE statements in ANY order and you can use options (usage, attributes, etc.) in ANY order within the DEFINE statement
|
|
What is wrong with the following?:
PROC REPORT DATA=beadata nowd; COLUMN year cocode sscode value; DEFINE value / spacing =4 format=comma25.; DEFINE cocode / right Country/Code width=7; WHERE sscode = "BEA120001" and year>=2007; RUN; |
SIngle quotes are required for 'Country/Code'. ’column-heading’ = label for column heading
Specify in quotes. Can use a slash or specify split option to split column headings. |
|
How is usage established for the following variables: DISPLAY, ORDER, GROUP, ACROSS, ANALYSIS, COMPUTED?
|
Usage is established in DEFINE statement
|
|
True or false. By default, CHAR vars = DISPLAY, NUMERIC vars = ANALYSIS which are used to calculate the SUM statistic.
|
True
|
|
What are the 3 basic procedures to produce descriptive statistics?
|
proc means
proc summary proc freq |
|
True or False. Proc means in its most basic form provides an n count, mean, standard deviation, maximum and minimum for all numeric variables EXCEPT year
|
False. Proc means in its most basic form provides an n count, mean, standard deviation, maximum and minimum for all numeric variables, EVEN year if it’s there.
|
|
How do you specify variables in proc means?
|
To specify variables in the proc means, you use the var statement:
proc means data=undex mean range std maxdec=3; var value; run; |
|
How can you group descriptive statistics?
|
There are two statements that can group descriptive statistics: class and by
proc means data=undex mean range std maxdec=3; var value; class year sscode; run; The other option is to use by, however, variables must be sorted by the by variable before it is used. proc means data=undex mean range std maxdec=3; var value; by year sscode; run; |
|
How can you output a dataset of descriptive statistics?
|
All it requires us to do is add the following line of code:
proc means data=undex maxdec=3; var value; by year sscode; output out=work.undtest mean=avgval; run; |
|
What's the differenct between PROC MEANS and PROC SUMMARY?
|
Proc summary has all the same functions and options as proc means, it just won’t produce report window output (unless you specific the print option)
|
|
What is the purpose of PROC FREQ?
|
Proc freq can produce 1 to n-way tables describing, primarily, the number of observations.
Crosstabulation tables can also be created. The basic form is: proc freq data=<dataset> <options>; run; |
|
How do you specify variables in PROC FREQ?
|
To specify the variables, we use the tables statement, which is best for categorical variables (i.e. year, sscode).
proc freq data=undex; tables year cocode sscode; run; |
|
How do you create a two way table using PROC FREQ?
|
A two-way table is done as follows:
proc freq data=undex; tables year*sscode; run; |
|
Name three kinds of listing output and their purpose
|
ods listing close; (if you don’t want listing output)
ods listing; (to reset ODS to listing default) ods _all_ close; (Closing Multiple ODS Destinations) |
|
What is the General form of ODS HTML to create a linked table of contents?
|
ODS HTML
BODY= file-specification CONTENTS=contents-file-specification FRAME=fram-file-specification; ODS HTML CLOSE; |
|
What are two options that can be specified with ODS?
|
1)PATH option
2)STYLE option |
|
How do you create SUM variables?
|
Variable + Expression. Variable specifies the name of the accumulator variable.
|
|
How do you initialize SUM variables?
|
Use the RETAIN statement to initialize variables--i.e.,:
RETAIN variable <initial-value>; retain cum_total_fa 314911551; |
|
How do you assign a Value conditionally?
|
To perform an action conditionally or assign a value conditionally, use an IF-THEN statement
if cocode = '6RWA' then Country = 'Rwanda'; |
|
How do you specify an alternative action after conditional statements?
|
Specify an alternative action using else statement
|
|
How do you specify lengths for variables?
|
Use LENGTH to specify a length for a variables:
LENGTH variables(s) <$> length; |
|
Name a way to subset data
|
Delete unwanted observations using:
IF expression THEN DELETE; |
|
Name one way to select variables in a dataset?
|
Use the KEEP or DROP statement
data example7 (drop=cocode); set example6; run; |
|
How can you permanently assign labels?
|
Use the LABEL statement
data example8 ; set example7; label fa = 'Foreign Assistance'; run; |
|
How can you assign values conditionally?
|
Use SELECT groups in DATA steps to perform conditional processing
select (Country); when ('Rwanda') Region='Africa'; otherwise Region='LA'; end; |
|
How do you group statements?
|
To execute a group of statements as a unit use DO Groups
do; amount= 'HIGH FA'; review = 'Y'; end; |
|
How do you use By Group Processing?
|
1. sort the data
2. FIRST.variable is 1 for the first observation in a BY GROUP, 0 for any other observation 3. LAST.variable is 1 for the last observation in a BY GROUP, 0 for any other observation |
|
How do you access observations directly?
|
To access observations directly, use POINT= with STOP (to avoid continuous looping)
DATA <work.data-set>; Obsnum= value; (must be before SET statement) SET <dataset> POINT=obsnum; STOP; (must use to prevent endless looping) Run; |
|
How can you write observations explicitly?
|
Use OUTPUT statement to override default way the DATA step writes observations to output
DATA <work.data-set>; Obsnum= value; (must be before SET statement) SET <dataset> POINT=obsnum; OUTPUT; STOP; (must use to prevent endless looping) Run; |
|
How do you detect the end of a dataset?
|
If you want to determine when the last observation has been read, use END= option in SET statement
DATA <data-set>; SET <data-set> end= last; run; |
|
True or False. You can use the END= and POINT= option together in a data step?
|
False. Do not use END= option and the POINT= option together. They are incompatible in the same SET statement.
|
|
A dataset is read in two steps, Compilation and execution. What happens in each?
|
Compilation:
1.PDV is created including _N_ and _ERROR_ 2.scan for syntax errors 3.each variable is added to the PDV 4.compilation ends with end of dataset is reached Execution: 1.At beginning, _N_ =1, _ERROR_=0, and all variables are assigned missing 2.values are added 3.computed values are added |
|
How do you STACK TWO OR MORE DATA SETS, ONE ON TOP OF EACH OTHER?
|
Use SET or PROC APPEND. PROC APPEND only allows appending two data sets
PROC APPEND BASE=esdb.frhdata DATA=work.update_frhdata FORCE; RUN; DATA dtug; SET esdb.frhdata work.update_frhdata; RUN; |
|
How do you PUT TWO OR MORE DATA SETS NEXT TO EACH OTHER?
|
USE SET OR MERGE for:
1)one-to-one reading 2)interleaving 3)match-merging |
|
How and why is One-to-one reading done?
|
DATA dtug;
SET esdb.frhdata; SET esdb.herdata; more SET statements as necessary... RUN; This is done to put observations next to each other until SAS encounters the end of any of the input data sets |
|
How and why is Interleaving done?
|
DATA interleaved;
SET frh her ; BY COCODE YEAR; RUN; Reads ALL input data so that the output data set contains the total number of input observations. Sorting is required. |
|
How and why is Match-Merging done?
|
DATA matchmerge;
MERGE frh her ; BY COCODE YEAR; RUN; SAS sequentially checks each observation of each data set to see whether the BY values match, then writes the combined observation |
|
How do you exclude unmatched observations ins a match-merge?
|
Use the IN= variable, which is temporary.
DATA matchmerge; MERGE frh(in=a) Her(in=b); BY COCODE YEAR; IF a and b; RUN; |
|
Which of the following is the correct form to use a SAS Function?
a. Function-name (argument-1, argument-n); b. mean (of x1-x3); c. mean (of newarray {*}) |
All of the above
|
|
If data is converted from Character-to-Numeric implicitly, what is the default format?
|
w.d
|
|
If data is converted from Numeric-to-Character implicitly, what is the default format?
|
BEST12.
|
|
How do you explicitly convert character to numeric?
|
Use INPUT (source, informat). source and informat are required
|
|
How do you explicitly convert Numeric-to-Character?
|
Use PUT (source, format). source and informat are required
|
|
What does the SAS function datetime() produce?
|
# seconds since midnight on Jan 1, 1960
|
|
True or False. The default YEARCUTOFF= is 1930.
|
False. The default YEARCUTOFF= is 1920.
|
|
What does the function INTCK do and what is its syntax?
|
Returns the number of time intervals in a given time span
INTCK(‘interval’, from, to) |
|
What does the function INTNX do and what is its syntax?
|
Applies multiples of a given interval to a date, time or datetime and returns the resulting value
x=intnx(‘interval’, start-from, increment, <’alignment’>); |
|
What does the function SCAN do and what is its syntax?
|
Returns a specified word from a character value
SCAN(argument, n, <delimiters>) |
|
What does the function SUBSTR do and what is its syntax?
|
Extract a portion of a character value OR replace the contents of a character value
SUBSTR(argument, position, <n>) |
|
What does the function TRIM do and what is its syntax?
|
Trims trailing blanks from character values
TRIM(argument) |
|
What does the function CATX do and what is its syntax?
|
Concatenates character strings, removes leading and trailing blanks, and inserts separators
CATX (separator, string-1, <…string-n>)argument) |
|
What does the function INDEX do and what is its syntax?
|
Searches a character value for a specific string
INDEX (source, excerpt) |
|
What does the function FIND do and what is its syntax?
|
Searches for a specific substring of characters within a specified character string
FIND (string, substring, <modifiers>, <startpos>) |
|
What does the function TRANWRD do and what is its syntax?
|
Replaces or removes all occurrences of a pattern of characters within a character string
TRANWRD (source, target, replacement) |
|
What does the function INT do and what is its syntax?
|
Returns the integer portion of a numeric value – any decimal portion is discarded
INT(argument) Rank=int(avrank); Avrank=3.755 Rank=3 |
|
What does the function ROUND do and what is its syntax?
|
Round to nearest specified unit
ROUND(argument, round-off-unit) |
|
What is the value of Year at the end of this DO LOOP?
data work.earn; Value=2000; do Year=1 to 20; Interest=value*.075; value+interest; end; run; |
Year = 21
|
|
True or False. The following produces 21 rows:
data work.earn2; Value=2000; do Year=1 to 20; Interest=value*.075; value+interest; output; end; run; |
False. Only 20 rows are produced
|
|
What are the two options for conditional do loop processing?
|
The two options are the Until Statement and While Statement. The main differences is that the Until statement is evaluated at the end of the loop, meaning the loop will always execute once, and the While statement is evaluated at the beginning, meaning the loop might not be executed.
|
|
How many observations does the following produce?:
data pts; do sample=5 to 500 by 5; set esdb.ptsdata point=sample; output; end; stop; run; |
100 observations
|
|
What is the syntax for an array?
|
ARRAY array-name{dimension} <elements>;
For example: array X_Years{4} X_2000 X_2001 X_2002 X_2003; |
|
How do you iterate through an array?
|
Use a do loop:
array X_Years{4} X_2000 X_2001 X_2002 X_2003; do i=1 to 4; X_Years{i}=0.7734*X_Years{i}; end; |
|
Which of the following are suitable array names: temp, substr, catx?
|
temp and catx
|
|
How do you create a character array?
|
Add a '$'. For example:
array country_name{3} $; |
|
sashelp.class contains 5 variables:
Name(char), Sex(char), Age(num), Height(num), Weight(num) What is the correct index for the following array that uses this data set?: array class_c{*} _character_; |
ANS: 2 because only 2 variables are characters
|
|
How do you ensure that array elements will NOT create new variables that appear in the resulting data set?
|
Temporary array elements will NOT create new variables that appear in the resulting data set
For example: array euro_convert{4} _temporary_ (1.0827 1.1166 1.0575 0.8840); |
|
What is the default length assigned to a character array?
|
The default length assigned is 8. Assign your own length by specifying the length after the dollar sign array firstname{5} $ 24;
|
|
The following is a multidimensional array:
array m{2,4} X_2000 X_2001 X_2002 X_2003 I_2000 I_2001 I_2002 I_2003; What variable is referred to by the 2nd row 3rd column? |
I_2002
|
|
What is the General form of COLUMN INPUT?
|
INPUT variable <$> startcol-endcol ;
$ - identifies the type as character if appears |
|
What should you use if your data contain nonstandard numeric data?
|
You should use FORMATTED INPUT, which uses column pointer controls to position the input pointer on specified column(s)
|
|
What does FORMATTED INPUT consist of?
|
It consists of 1) @n is an absolute pointer; 2) +n is a relative pointer
|
|
What is used to tell SAS how to read standard and non-standard data values?
|
INFORMATS
|
|
What are 3 types of INFORMATS?
|
1) Character value formats - $w.
2) Standard numeric data – w.d 3) Nonstandard numeric -e.g., COMMAw.d |
|
What is the purpose of the PAD option?
|
It's used when reading variable-length recods that contain fixed field data. The PAD option pads each record with blanks so that all data lines ahve the same length
|
|
Name the two categories of data when performing a read?
|
1)Fixed fields
2)Free-format |
|
Is the following an example of fixed fields or Free-format data?
Input @1 cocode $4. @6 coname $11. ; |
Fixed fields
|
|
Is the following an example of fixed fields or Free-format data?
Input cocode $ coname : $11. ; |
Free-format data
|
|
What are the 3 primary input styles that SAS provides?
|
1)Column
2)Formatted 3)List |
|
What is the GENERAL form for list input?
|
INPUT variable1 <$> variable2 <$> … variablen <$>;
|
|
What is false regarding the defaults for list input?
1. Length 8 for both character and numeric variables – leads to truncation. 2. Values must be standard character or numeric format. 3. Characters values can’t contain delimiters embedded within. 4. Missing values must be represented by a period or other character. |
None are false. They are all true.
|
|
Name three options for the INFILE statement?
|
1. DLM= place the delimiter in quote marks
2. MISSOVER missing values at the end of a record 3. DSD Reading missing values in the beginning or middle of a record |
|
What is SAS’s term for when you use the ampersand (&) or colon (:)?
|
Modified list input
|
|
What is the date value for 0?
|
Jan. 1, 1960
|
|
What is the Date INFORMAT for each of the following?:
02Jan00 01-02-2000 02/01/00 2000/01/02 |
Respective Date INFORMATS:
DATEw. MMDDYYw. DDMMYYw. YYMMDDw. |
|
Regarding TIME values, which of the following is false?
1. Based on Gregorian calendar, from A.D. 1582 – A.D. 20000 2. SAS adjusts for leap years, BUT IGNORES leap seconds. 3. SAS adjusts for daylight saving time. |
#3 is false. SAS DOES NOT adjust for daylight saving time.
|
|
What is the GENERAL form to specify INFORMATS?
|
INPUT <pointer-control> variable informat.;
|
|
True or False. YEARCUTOFF= only affects 2-digits year values
|
TRUE
|
|
What is the DEFAULT for the YEARCUTOFF= option?
|
1920
|
|
What special character(s) is used to read the records in a raw data file sequentially?
|
use the forward slash (/) line pointer control to read the records in a raw data file sequentially
|
|
What special character(s) is used to read the records in a raw data file non-sequentially?
|
use the pound-n (#n) line pointer control to read the records in a raw data file non-sequentially
|
|
What tells SAS to advance to a new record before reading the next data value?
|
a Line Pointer Control
|
|
True or False. The forward slash (/) and the #n pointer control can be used together to read records both sequentially and non-sequentially
|
True
|
|
Line hold specifiers are used to handle data with several observations in one record. Name three examples of several observations in one record
|
1. Repeating blocks
2. one ID field with repeat fields 3. Varying number of repeating fields |
|
What holds the current record to produce list output?
|
Line-Hold Specifiers hold the current record to produce list output (e.g., @ or @@)
|
|
True or False. A double trailing @@ should only be used with list input
|
True. A double trailing @@ should only be used with list input (and not column input); otherwise, and infinite loop can result. Do not use it with MISSOVER
|
|
True or False. It's ok to mix use of the single trailing @ and the double trailing @
|
False. The single trailing @ and the double trailing @ are mutually exclusive. Do not use them together
|
|
The Double Trailing @ holds until...
|
1) the end of the line or record
2) until it hits an INPUT statement with no line-hold specifiers |
|
The Trailing @ holds until...
|
1) An INPUT statement with no trailing @
2) The bottom of the Data Step |
|
statement to keep the Header variables that we want to output
|
RETAIN
|
|
special character on the INPUT to hold records for processing later in the DATA step
|
Trailing @
|
|
Used to execute statements depending on the type of record (H vs. D)
|
IF - THEN - ELSE
|
|
automatic variable to detect the first Header record for unique treatment
|
_N_
|
|
statement to explicitly control which records are output and which are not
|
OUTPUT
|
|
used to calculate the summary info we want
|
Sum statement
|
|
option on the INFILE statement to detect the last record for explicit output
|
END=
|
|
option on the DATA statement to exclude variables from the output
|
DROP=
|