Académique Documents
Professionnel Documents
Culture Documents
10) What are the new features included in the new version
of SAS i.e., SAS9.1.3?
The main advantage of version 9 is faster execution of applications
and centralized access of data and support.
11) WHAT DIFFERRENCE DID YOU FIND AMONG VERSION 6
8 AND 9 OF SAS.
16) What other SAS products have you used and consider
yourself proficient in using?
Data _NULL_ statement, Proc Means, Proc Report, Proc tabulate,
Proc freq and Proc print, Proc Univariate etc.
20) What do the MOD and INT function do? What do the PAD
and DIM functions do?
DATA NEW ;
A = 123456 ;
X = INT( A/1000 ) ;
Y = MOD( A, 1000 ) ;
Z = MOD( INT( A/100 ), 100 ) ;
PUT A= X= Y= Z= ;
RUN ;
A=123456
X=123
Y=456
Z=34
Very Basic:
· What SAS statements would you code to read an external
raw data file to a DATA step?
INFILE statement.
Using Input statement with the column pointers like @5/12-17 etc.
· Are you familiar with special input delimiters? How are they
used?
DLM and DSD are the delimiters that I’ve used. They should be
included in the infile statement. Comma separated values files or
CSV files are a common type of file that can be used to read with
the DSD option. DSD option treats two delimiters in a row as
MISSING value. DSD also ignores the delimiters enclosed in
quotation marks.
· Name and describe three SAS functions that you have used,
if any?
Double trailing @@: When you have multiple observations per line
of raw data, we should use double trailing signs (@@) at the end of
the INPUT statement. The line hold specifies like a stop sign telling
SAS, “stop, hold that line of raw data”.
· If you're not wanting any SAS output from a data step, how
would you code the data statement to prevent SAS from
producing a set?
Data _Null_
Options statement: This a part of SAS program and effects all steps
that follow it.
· Have you ever linked SAS code? If so, describe the link and
any required statements used to either process the code or
the step itself.
SCAN.
· If you have a data set that contains 100 variables, but you
need only five of those, what is the code to force SAS to use
only those variable?
Using KEEP option or statement.
NONUPLICATES
NODUPKEY
· How would you code a merge that will keep only the
observations that have matches from both sets.
· How would you code a merge that will write the matches of
both to one data set, the non-matches from the left-most
data.
Step1: Define 3 datasets in DATA step
Step2: Assign values of IN statement to different variables for 2
datasets
Step3: Check for the condition using IF statement and output the
matching to first dataset and no matches to different datasets
Ex: data xxxmerge yyy(in = inxxx) zzz (in = inzzz);by aaa;if inxxx
= 1 and inyyy = 1;run;
PUT
INFILE, INPUT
INPUT
The DATA step begins with a DATA statement. Each time the DATA
statement executes, a new iteration of the DATA step begins, and
the _N_ automatic variable is incremented by 1.
· What is _n_?
It is a Data counter variable in SAS.
Note: Both -N- and _ERROR_ variables are always available to you
in the data step.
–N- indicates the number of times SAS has looped through the data
step.
This is not necessarily equal to the observation number, since a
simple sub setting IF statement can change the relationship
between Observation number and the number of iterations of the
data step.
The –ERROR- variable ha a value of 1 if there is a error in the data
for that observation and 0 if it is not. Ex: This is nothing but a
implicit variable created by SAS during data processing. It gives the
total number of records SAS has iterated in a dataset. It is Available
only for data step and not for PROCS. Eg. If we want to find every
third record in a Dataset thenwe can use the _n_ as follows Data
new-sas-data-set;Set old;if mod(_n_,3)= 1 then;run;Note: If we
use a where clause to subset the _n_ will not yield the required
result.
A: I think Select statement are used when you are using one
condition to compare with several conditions like
select pass
when Physics >60
when math > 100
when English = 50;
otherwise fail;
What is the one statement to set the criteria of data that can
be coded
in any step?
A) Options statement.
What other SAS features do you use for error trapping and
data
validation?
A) Check the Log and for data validation things like Proc Freq, Proc
means or some times proc print to look how the data looks like
........
other questions:
What can you learn from the SAS log when debugging?
It will display the execution of whole program and the logic. It will
also display the error with line number so that you can and edit the
program.
What is the purpose of _error_?
It has only to values, which are 1 for error and 0 for no error
What is the one statement to set the criteria of data that can
be coded in any step? OPTIONS Statement, Label statement,
Keep / Drop statements.
hat are the new features included in the new version of SAS
i.e., SAS9.1.3?
The main advantage of version 9 is faster execution of applications and
centralized access of data and support.
There are lots of changes has been made in the version 9 when we
compared with the version 8. The following are the few:
SAS version 9 supports Formats longer than 8 bytes & is not
possible with version 8.
Length for Numeric format allowed in version 9 is 32 where as 8 in
version 8.
Length for Character names in version 9 is 31 where as in version 8
is 32.
Length for numeric informat in version 9 is 31, 8 in version 8.
Length for character names is 30, 32 in version 8.
3 new informats are available in version 9 to convert various date,
time and datetime forms of data into a SAS date or SAS time. ·
What do the MOD and INT function do? What do the PAD and
DIM functions do? MOD: Modulo is a constant or numeric
variable, the function returns the reminder after numeric value
divided by modulo.
PAD: it pads each record with blanks so that all data lines have the
same length. It is used in the INFILE statement. It is useful only
when missing data occurs at the end of the record.
CATX: concatenate character strings, removes leading and trailing
blanks and inserts separators.
SCAN: it returns a specified word from a character value. Scan
function assigns a length of 200 to each target variable.
SUBSTR: extracts a sub string and replaces character values.
Extraction of a substring: Middleinitial=substr(middlename,1,1);
Replacing character values: substr (phone,1,3)=’433’; If SUBSTR
function is on the left side of a statement, the function replaces the
contents of the character variable.
TRIM: trims the trailing blanks from the character values.
What other SAS features do you use for error trapping and
data validation? What are the validation tools in SAS?
For dataset: Data set name/debug
Data set: name/stmtchk
For macros: Options:mprint mlogic symbolgen.
How would you code a merge that will keep only the
observations that have matches from both data sets?
Using "IN" variable option. Look at the following example.
data three;
merge one(in=x) two(in=y);
by id;
if x=1 and y=1;
run;
or
data three;
merge one(in=x) two(in=y);
by id;
if x and y;
run;
Have you ever-linked SAS code, If so, describe the link and
any required statements used to either process the code or
the step itself?
In the editor window we write
%include 'path of the sas file';
run;
1. Have you used macros? For what purpose you have used?
Yes I have, I used macros in creating analysis datasets and tables
where it is necessary to make a small change through out the
program and where it is necessary to use the code again and again.
15. Can you execute macro within another macro? If so, how
would SAS know where the current macro ended and the
new one began?
Yes, I can execute macro within a macro, what we call it as nesting
of macros, which is allowed. Every macro's beginning is identified
the keyword %macro and end with %mend.
27. Can you execute macro within another macro? If so, how
would SAS know where the current macro ended and the
new one began?
Yes, I can execute macro within a macro, what we call it as nesting
of macros, which is allowed. Every macro's beginning is identified
the keyword %macro and end with %mend.
32. What are the macros you have used in your programs?
Used macros for various puposes, few of them are..
%varlist(adverse)
2) Distribution or Missing / Non-Missing Values
%macro missrep(dsn, vars=_numeric_);
proc freq data=&dsn.;
tables &vars. / missing;
format _character_ $missf. _numeric_ missf.;
title1 ‘Distribution or Missing / Non-Missing Values’;
run;
%mend missrep;
%missrep(study.demog, vars=age gender bdate);
data &dsnsplit2;
set &dsnorig (firstobs = %eval(&obs1 + 1));
run;
%mend split;
%split(sasuser.admit,admit4,admit5,2)
33. What is auto call macro and how to create a auto call
macro? What is the use of it? How to use it in SAS with
macros?
Enables the user to call macros that have been stored as SAS
programs. The auto call macro facility allows users to access the
same macro code from multiple SAS programs. Rather than having
the same macro code for in each program where the code is
required, with an autocall macro, the code is in one location. This
permits faster updates and better consistency across all the
programs.
Macro set-up:
The fist step is to set-up a program that contains a macro, desired
to be used in multiple programs. Although the program may contain
other macros and/or open code, it is advised to include only one
macro.
Set MAUTOSOURSE and SASAUTOS:
Before one can use the autocall macro within a SAS program, The
MAUTOSOURSE option must be set open and the SASAUTOS option
should be assigned. The MAUTOSOURSE option indicates to SAS
that the autocall facility is to be activated. The SASAUTOS option
tells SAS where to look for the macros.
For ex: sasauto=’g:\busmeas\internal\macro\’;