Format statement. What is it under?
FORMAT variable(s) format;
Under PROC PRINT
What date has the SAS date value of zero?
Jan 1, 1960
How to create your own format?
PROC FORMAT;
VALUE format-name value-or-range1= ‘formatted-value1’
value-or-range2=’formatted-value2’
…..;
RUN;
Rules for format name
How do you exclude the highest or lowest number from a range (when you’re making own format)?
1<-10 excludes 1
1-<10 excludes 10
Note: Cannot use > sign
What keywords can you use in a range (while making on format) if you don’t know the highest or lowest values in the data set?
low (for lowest value)
high (for highest value)
How to you make a new data set that’s a subset of another data set?
DATA output-SAS-data-set;
SET input-SAS-data-set;
WHERE variable=condition;
RUN;
How can you compare a SAS date value to a calendar date?
Use SAS Date Constant instead of the SAS date value:
‘ddmmm(yy)yy’D
e.g. ‘01JAN2000’D
How do you create a new variable or assign a value to an existing variable?
Use assignment statement:
variable=expression;
What happens if a variable in an arithmetic expression has a missing value?
The result is a missing value
How do you exclude variables from a data set?
DROP variables;
KEEP variables;
What happens in the Compilation Phase of a DATA step?
What happens in the Execution Phase of a DATA Step?
SAS reads and processes observations from input data set.
Creates observations in the data portion of the output data set
What happens if you use the WHERE statement to include a variable that you created (it’s not on the original data set)? What can you do instead?
ERROR. SAS can’t read the variable because is not on the original data set.
Use IF expression;
How is WHERE statement different from IF?
How do you assign permanent labels?
Use LABEL variable=’label’; in a DATA Step rather than a PROC step. Remember to still add label to PROC print step
How to add permanent formats?
Use FORMAT statment within DATA step
General form of SAS formats
($)formatname(w).(d)
$ is for character formats
w is total width
d specifies decimal places for numeric formats