SAS Interview Questions And Answers
Download SAS Interview Questions and Answers PDF
Optimize your SAS interview preparation with our curated set of 11 questions. Our questions cover a wide range of topics in SAS to ensure you're well-prepared. Whether you're new to the field or have years of experience, these questions are designed to help you succeed. Access the free PDF to get all 11 questions and give yourself the best chance of acing your SAS interview. This resource is perfect for thorough preparation and confidence building.
11 SAS Questions and Answers:
SAS Job Interview Questions Table of Contents:
1 :: Suppose date is 05sep2005; i want the output like 05sep2005:00:00:00 ; how it will come?
data test_date;
input date;
informat date datetime18;
cards;
05sep2005:00:00:00
run;
proc print data=test_date;
format date datetime18.;
run;
Read Moreinput date;
informat date datetime18;
cards;
05sep2005:00:00:00
run;
proc print data=test_date;
format date datetime18.;
run;
2 :: What is option year cuttoff in sas?
by this option we can set the year span like
Options yearcutoff=2050
so it sets year from 2050 to 2049 ..
Read MoreOptions yearcutoff=2050
so it sets year from 2050 to 2049 ..
3 :: How to CREATE an external dataset with sas code?
I thought about sth like this:
Data _null_;
filename fileref <device-type>
dsnname='path'
run;
something like this buy it do not work.
and i would like to add BLK, DISP; UNIT SIZE
Read MoreData _null_;
filename fileref <device-type>
dsnname='path'
run;
something like this buy it do not work.
and i would like to add BLK, DISP; UNIT SIZE
4 :: How to add a number to a macro variable?
Use %eval to do simple calculation for macro variables.
e.g.,
data _null_;
%let a = 1;
%let b = %eval(&a+1);
%put a=&a b=&b;
run;
Read Moree.g.,
data _null_;
%let a = 1;
%let b = %eval(&a+1);
%put a=&a b=&b;
run;
5 :: Code the tables statement for a single-level (most common) frequency?
one level: tables a b c;
Read More6 :: Code the tables statement to produce a multi-level frequency?
multiple levels: tables a*b a*c a*b*c;
Read More7 :: In PROC PRINT, can you print only variables that begin with the letter “A”?
Use the idea of variable list (varlist) wildcard :
e.g.,
proc print data=xxx ;
var A: ;
run ;
This will list all variables start with letter A.
Read Moree.g.,
proc print data=xxx ;
var A: ;
run ;
This will list all variables start with letter A.
8 :: Suppose a dataset with 100000 records. i want 100 records from that dataset and create a dataset.we need to pick the observations random order like
100obs,500obs,1020obs,1890obs,2565obs like that i need 100 obs in random order? how can we create this one?
data A;
do slice = 100,500,1890,256,...100th;
set source point=slice;
output;
end;
stop;
run;
Read Moredo slice = 100,500,1890,256,...100th;
set source point=slice;
output;
end;
stop;
run;
9 :: What is validvarname and varnum? why we are using this options; explain with a syntax for this options?
The following example shows how the Pass-Through Facility
works with
VALIDVARNAME=UPPERCASE.
options validvarname=uppercase;
proc sql;
connect to oracle as tables(user=USERID orapw=passward
path=’INSTANCE’);
create table lab as
select lab_rslt, lab_test
from connection to oracle
(select "laboratory result$", "laboratory test$"
from DBMStable);
quit;
When we check the Output we observe that the variables in
the DBMS column is changed to upper case as well as V7
(default option) converts those variables into UPPERCASE
variables. Ex: " laboratory result$" becomes LAB_RSLT and "
laboratory test$" becomes LAB_TEST
VARNUM returns the number of a variable's position in a SAS
data set, or 0 if the variable is not in the SAS data set.
This is the same variable number that is next to the
variable in the output from PROC CONTENTS.
Read Moreworks with
VALIDVARNAME=UPPERCASE.
options validvarname=uppercase;
proc sql;
connect to oracle as tables(user=USERID orapw=passward
path=’INSTANCE’);
create table lab as
select lab_rslt, lab_test
from connection to oracle
(select "laboratory result$", "laboratory test$"
from DBMStable);
quit;
When we check the Output we observe that the variables in
the DBMS column is changed to upper case as well as V7
(default option) converts those variables into UPPERCASE
variables. Ex: " laboratory result$" becomes LAB_RSLT and "
laboratory test$" becomes LAB_TEST
VARNUM returns the number of a variable's position in a SAS
data set, or 0 if the variable is not in the SAS data set.
This is the same variable number that is next to the
variable in the output from PROC CONTENTS.
10 :: Suppose a null dataset with 10 variables; i want to print only name of the varibales in log window and also output window. How can we do this one?
data sm;
input name $ number;
datalines;
run;
dataset in created without observations but the dataset has
varibles.
Read Moreinput name $ number;
datalines;
run;
dataset in created without observations but the dataset has
varibles.
11 :: What is the use of catalog?
SAS CATALOG IS A TYPE OF SPECIAL SAS FILE THAT CONTAINS
ELEMENTS.MOST COMMMON ELEMENTS IN SAS CATALOG ARE 'FORMAT'
'SOURCE' OUTPUT,LOG EC.
PROC FORMAT IS USED TO CREATE THE FORMAT AND STORE THEN
IN THE SASCATALOG.
proc format library=SMA;
value $region
'1'='n orthwest'
'2'='southwest'
'3'='central'
;
run;
FORMAT NAME 'REGION' IS STORED IN CATALOG IN 'SMA' LIBRARY
TO KNOW THE CONTENTS OR TO MOVE THE CONTENTS OF ASA CATALOG
USE THE PROCEDURE 'PROC CATALOG'
Read MoreELEMENTS.MOST COMMMON ELEMENTS IN SAS CATALOG ARE 'FORMAT'
'SOURCE' OUTPUT,LOG EC.
PROC FORMAT IS USED TO CREATE THE FORMAT AND STORE THEN
IN THE SASCATALOG.
proc format library=SMA;
value $region
'1'='n orthwest'
'2'='southwest'
'3'='central'
;
run;
FORMAT NAME 'REGION' IS STORED IN CATALOG IN 'SMA' LIBRARY
TO KNOW THE CONTENTS OR TO MOVE THE CONTENTS OF ASA CATALOG
USE THE PROCEDURE 'PROC CATALOG'