SAS Interview Questions: Arundathi Infotech
SAS Interview Questions: Arundathi Infotech
SAS Interview Questions: Arundathi Infotech
www.arundathiinfotech.com
SAS interview
Questions
# 605, Annapurna Block, Adithya Enclave,
Ameerpet, Hyd. Ph: 900!""#5",
0$0%66#5#5$5
&&&.arundathiin'otech.com
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
+
SAS Faqs
www.arundathiinfotech.com
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
*
SAS Faqs
www.arundathiinfotech.com
SAS interview Questions and Answers
". What is the purpose of the statement DATA_NULL_ ?
Ans: Use the keyword _NULL_, which allows the power of the DATA step without creating a data
set.
2. What is use of CALNDA! pro"edure
Displays data from a A data set in a monthly calendar format. !"#$ $AL%NDA" can display
holidays in the month, schedule tasks, and process data for multiple calendars with work schedules
that &ary
#. $ANS or SU$$A!%
computes descripti&e statistics' can produce printed output and output data sets. (y default, !"#$
)%AN produces printed output and !"#$ U))A"* creates an output data set.
&. 'NT!LA('N)
+nterlea&ing uses a %T statement and a (* statement to com,ine multiple data sets into one new data
set. The num,er of o,ser&ations in the new data set is the sum of the num,er of o,ser&ations from the
original data sets. -owe&er, the o,ser&ations in the new data set are arranged ,y the &alues of the (*
&aria,le or &aria,les and, within each (* group, ,y the order of the data sets in which they occur. *ou
can interlea&e data sets either ,y using a (* &aria,le or ,y using an inde..
*+,!T en-ine with DATA step or +!,C C,+%
At the source operating en&ironment, the L+(NA)% statement with the /!#"T engine and
either the DATA step or !"#$ $#!* creates a data file in transport format. At the target
operating en&ironment, the same method is used to translate the transport file into the target
operating en&ironment nati&e format.
.. C+,!T and C'$+,!T pro"edures
At the source operating en&ironment, !"#$ $!#"T writes data sets or catalogs or ,oth data sets and
catalogs to transport format. At the target operating en&ironment, !"#$ $+)!#"T translates the
transport file into the target operating en&ironment nati&e format
/. %ou "an position the input pointer on a spe"ifi" re"ord 01 usin-
a. column pointer controls.
,. column specifications.
c. line pointer controls.
D line hold specifiers.
2. Whi"h pointer "ontro3 is used to read mu3tip3e re"ords se4uentia331?
a. 0n
,. 1n
c. 2
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
)
SAS Faqs
www.arundathiinfotech.com
all of the a,o&e
3. 4hich is true for the dou,le trailing at sign 50067
a. +t ena,les the ne.t +N!UT statement to read from the current record across multiple iterations
of the DATA step.
,. +t must ,e the last item that is specified in the +N!UT statement.
c. +t is released when the input pointer mo&es past the end of the record.
d. All of the a,o&e.
5. when A re"ord that is 0ein- he3d 01 a sin-3e trai3in- at si-n 678 is automati"a331 re3eased
a. the input pointer mo&es past the end of the record.
,. the ne.t iteration of the DATA step ,egins.
c. another +N!UT statement that has a single trailing at sign 506 e.ecutes.
d. another &alue is read from the o,ser&ation.
9:. Wht is the purpose of usin- the N;+S option?
Ans, Specifyin- $ . #S, in the F/0 statement allows the output points to
write on any line of the current output.
"". Ho& do the ()* varia+le improve the capa+ility o' a ,E-.E/
Ans, /$ is a implicit !aria1le in SAS which helps in controllin- which
dataset needs to contri1ute to the new dataset.
"!. 0ht i1 the di2erence +3& calculatin4 the 5mean6 u1in4 the mean
'unction and P-78 ,EA)9/
Ans, 2he mean function returns the mean of the non%missin- !alues in the
!aria1le list. Actually, u may not ha!e 3-ured out the importance of the
way the 4A$ function deals with the missin- !alues, and this is quite
important. /f u calculate S567 1y simply addin- up all the items and
di!idin- 1y 50 as follows..
S567 . 8item+ 9 item* 9 item)9::9item50;<50=
>ou would 1e in 1i- trou1le if any of the items had missin- !alues. ?hen
SAS statement tries to do arithmetic operation on missin- !alues, the
result is always missin-.
". Ho& many mi11in4 value1 are availa+le /&hen mi4ht u u1e them/
Ans, 2wo missin- !alues are a!aila1le in SAS, they are numeric and
character.
"ow do u test for missin- !alues@
Ans, ?e can test the missin- !alues 1y usin- $4/SS option in the /nput
statement.
"$. Ho& are numeric and character mi11in4 value1 repre1ented
internally/
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
&
SAS Faqs
www.arundathiinfotech.com
Ans, 2he numeric !alues are represented 1y dots 8.; and the character
missin- !alues r represented 1y 1lank.
"5. 0hat do the P:; and ()P:; 'unction1 do/
Ans, the #A2 function is used to identify the lo-ic pro1lem which piece of
code is eBecuted and not eBecuted wht the current !alue of the particular
!aria1le and wht the current !alue of the all !aria1le.
/$#A2 Function, 2he traditional use is the reread a character !aria1le with
a numeric format, eBecute a character Cto%numeric con!ersion.
"6. Have u ever%linked 9A9 code/ (' 1o, de1cri+e the like and any
re<uired 1tatement u1ed to either proce11 the code or the 1tep it1el'.
Ans, 2he link statement tells SAS to Dump immediately to the statement
la1el that is indicated in the 0AB0 statement and to continue eBecutin-
statements from that point until a 72A7$ statement is eBecuted. 2he
72A7$ statement ends pro-ram control to the statement immediately
followin- the 0/$E statement.
$62, the 0/$E statement and the destination must 1e in the same FA2A
step. 2he destination is identi3ed 1y a statement la1el in the 0/$E
statement.
"#. Ho& &ould u include common or reu1e code to +e proce11ed alon4
&ith ur 1tatement/
Ans, By usin- G/$50AF
"=. 0hen lookin4 'or the data contained in a character 1trin4 o' "50
+yte1, &hich 'unction i1 the +e1t to locate that data: 98A), ()>E?, or
()>E?8/
Ans, S5A$.
"9. (' u have a data 1et that contain1 "00 varia+le1, +ut u need only 5
o' tho1e, &ht i1 the code to 'orce 9A9 to u1e only tho1e varia+le1/
Ans, Ase E# . option=
!0. 8ode a P-78 97-; on a data 1et containin4 1tate, di1trict and
country a1 the primary varia+le, alon4 &ith 1everal numeric varia+le1.
Ans, #65 S672 data%set%name=
B> state district country=
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
5
SAS Faqs
www.arundathiinfotech.com
7A$=
!". Ho& &ould u delete duplicate o+1ervation/
Ans, 2here r three ways to delete duplicate o1ser!ations in a dataset.
#765 S672 Fata . SAS%data%set NODUPS=
By !ar=
7A$=
#765 SH0=
57A2 sas%data%set% as S052 I F764
oldJsasJdataJset ?"7 !ar . DISTINCT8!ar;=
HA/2=
Fa ta CLEAN=
S2 temp=
B> -roup=
/F 3rst.-roup and last.-roup 2"$
7A$=
!!. 0ht i1 the Pro4ram >ata @ectorAP.>.@B/ 0ht r their 'unction1/
Ans,
#.F.K is the temporary holdin- area. For eBample :2he ?"7 statement is may
1e more eLcient then the su1 settin- /F 8especially if u r takin- a small su1set
from a !ery lar-e 3le ; 1ecause it checks on the !alidity of the condition to see if
the o1ser!ation is to 1e kept or not. 2his temporary holdin- area is called the
#ro-ram Fata Kector8#.F.K;.
!. Ho& &ould u code a mer4e that &ill keep only the o+1ervation that
have matche1 'rom +oth 1et1/
Ans, By usin- the /$ internal !aria1le in the mer-e statement.
FA2A $ew=
47M 6neJtemp 8/$. 6$; 2woJtemp8/$.2?6;=
B> $ame=
/F 6$ . + A$F 2?6 . +=
7A$=
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
6
SAS Faqs
www.arundathiinfotech.com
!$ . >oe1 9A9 5;ran1late6 A8ompileB or >oe1 it 5(nterpret6/
Ans, ?hen u su1mits a FA2A step for Becution, SAS checks the syntaB of
the SAS statements and compiles them, that is, automatically translates
the statements into machine code. /n this phase, SAS identi3es the type
and a len-th of each new !aria1le, and determines whether a type
con!ersion is necessary for each su1sequent reference to a !aria1le.
!5. At compile time &hen a 9A9 data 1et i1 read, 0ht item1 are
created/
Ans, At 5ompile time SAS 5reates the followin-
/nput BuNer
#ro-ram Fata Kector 8#.F.K;
Fescriptor /nformation
!6. )ame 1tatement1 that r reco4niCed at compile time only/
Ans, F76# , E#,.., e.t.c.
!#. (dentimetn'y 1tatement1 &ho1e placement in the >A;A 1tep i1
critical.
Ans, /$#A2 statement.
!=. )ame 1tatement1 that 'unction at +oth compile and EDecution
time.
$ame statements that r eBecution only.
!9. (n the Eo& o' the >A;A 1tep proce11in4, &ht i1 the Fr1t action in
a typical >A;A 1tep/
Ans, SAS 3rst performs SyntaB check.
0. 0ht i1 GnG/
Ans, 2his is nothin- 1ut a implicit !aria1le created 1y SAS durin- data
processin-. /t -i!es the total num1er of records SAS has iterated in a
dataset. /t is a!aila1le only for Fata Step and not for #rocs.
.M, /f we want to 3nd e!ery )
rd
record in a Fataset then we can use the
JnJ as follows..
S2 old=
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
'
SAS Faqs
www.arundathiinfotech.com
/F 46F8JnJ, ); . + then=
7un=
$ote, /f we use a where clause to su1set the JnJ , ?ill not yield the required
result.
" 0hat i1 the purpo1e o' u1in4 the )*P9 option/
Ans: The N8! option creates a ,uffer in memory which is large enough to store
!A9%+:% 5!6 lines and ena,les a page to ,e formatted randomly prior to it ,eing printed.
Ans N8! option allows access to full page at one time.
#2 What is the differen"e 0etween pro" sort nodup and pro" sort nodup<e1?
Ans:pro" sort nodup gets rid of dup3i"ate re"ords with the same sort key ,ut pro" sort nodup<e1
gets rid of other records with the same sort key;. -owe&er, this is not "orre"t.
OnodupO is an alias for OnoduprecsO which appears to mean Ono duplicate
recordsO 1ut there is no way sas can know a1out these duplicate records unless
they, 1y chance, land neBt to each other in sequence. 2hat is a matter of chance.
2ake a look at OnodupO at work. $ote the record with the OeBtraO !alue of ). /tPs
still there after the OnodupO sort.
33. Does SAS 'Translate'(compile)or does it 'Interpret'? Explain.
A compiles the code< At compile time when a A data set is read, what items are created7
Automatic &aria,les are created. +nput (uffer, !D= and Descriptor +nformation
#& . Name statements that are re"o-ni=ed at "ompi3e time on31?
!UT
#. . Name statements that are e>e"ution on31.
+N>+L%, +N!UT<
#/ . 'dentif1 statements whose p3a"ement in the DATA step is "riti"a3.
DATA, +N!UT, "UN.
#2. Name statements that fun"tion at 0oth "ompi3e and e>e"ution time.
+N!UT
#?. 'n the f3ow of DATA step pro"essin-@ what is the first a"tion in a t1pi"a3 DATA Step?
The DATA step ,egins with a DATA statement. %ach time the DATA statement e.ecutes, a new
iteration of the DATA step ,egins, and the _N_ automatic &aria,le is incremented ,y ?.
#5. What is _n_?
+t is a Data counter &aria,le in A.
Note: (oth @N@ and _%""#"_ &aria,les are always a&aila,le to you in the data step
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
Q
SAS Faqs
www.arundathiinfotech.com
.AN@ indicates the num,er of times A has looped through the data step.This is not necessarily eBual
to the o,ser&ation num,er, since a simple su, setting +> statement can change the relationship
,etween #,ser&ation num,er and the num,er of iterations of the data step.The A%""#"@ &aria,le ha
a &alue of ? if there is a error in the data for that o,ser&ation and C if it is not. %.: This is nothing ,ut a
implicit &aria,le created ,y A during data processing. +t gi&es the total num,er of records A has
iterated in a
&: . Ain"3ude statementB
which looks like a macro ,ut isnDt really, sucks the contents of the Eust@generated file into the input
stream. The result will ,e that the step will effecti&ely contain all of the rename statements generated
in the pre&ious step, accomplishing the renaming of all columns.
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
(
SAS Faqs
www.arundathiinfotech.com
$" . Ho& do the ()* varia+le1 improve the capa+ility o' a ,E-.E/
A; 2he /$.!aria1les ?hat if you want to keep in the output data set of a mer-e
only the matches 8only those o1ser!ations to which 1oth input data sets
contri1ute;@ SAS will set up for you special temporary !aria1les, called the O/$.O
!aria1les, so that you can do this and more. "erePs what you ha!e to do, si-nal
to SAS on the 47M statement that you need the /$. !aria1les for the input
data set8s; use the /$. !aria1les in the data step appropriately, So to keep only
the matches in the match%mer-e a1o!e, ask for the /$. !aria1les and use
them,data three=mer-e one8in.B; two8in.y;= <I B R y are your choices of names
I<1y id= <I for the /$. !aria1les for data I<if B.+ and y.+= <I sets one and two
respecti!ely I<run=
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
+0
SAS Faqs
www.arundathiinfotech.com
$!. 0hat techni<ue1 and3or P-781 do you u1e 'or ta+le1/
A; #roc Freq, #roc uni!ariate, #roc 2a1ulate R #roc 7eport.
$ . >o you pre'er P-78 -EP7-; or P-78 ;AB:HA;E/ 0hy/
A; / prefer to use #roc report until / ha!e to create cross ta1ulation ta1les,
1ecause, /t -i!es me so many options to modify the look up of my ta1le, 8eB,
?idth option, 1y this we can chan-e the width of each column in the ta1le;
?here as #roc ta1ulate una1le to produce some of the thin-s in my ta1le. B,
ta1ulate doesnSt produce n 8G; in the desira1le format.
$$ . Ho& eDperienced are you &ith cu1tomiCed reportin4 and u1e o'
>A;A G):HHG 'eature1/
A; / ha!e !ery -ood eBperience in creatin- customiTed reports as well as with
Fata J$A00J step. /tSs a Fata step that -enerates a report without creatin- the
dataset there 1y de!elopment time can 1e sa!ed. 2he other ad!anta-es of Fata
$A00 is when we su1mit, if there is any compilation error is there in the
statement which can 1e detected and written to the lo- there 1y error can 1e
detected 1y checkin- the lo- after su1mittin- it. /t is also used to create the
macro !aria1les in the data set.
$5. 0hat i1 the di2erence +et&een nodup and nodupkey option1/
A; $6FA# compares all the !aria1les in our dataset while $6FA#E> compares
Dust the B> !aria1les.
$6. 0hat i1 the di2erence +et&een compiler and interpreter/
Mi!e any one eBample 8software product; that act as an interpreter@
A; Both are similar as they achie!e similar purposes, 1ut inherently diNerent as
to how they achie!e that purpose. 2he interpreter translates instructions one at a
time, and then eBecutes those instructions immediately. 5ompiled code takes
pro-rams 8source; written in SAS pro-rammin- lan-ua-e, and then ultimately
translates it into o1Dect code or machine lan-ua-e. 5ompiled code does the work
much more eLciently, 1ecause it produces a complete machine lan-ua-e
pro-ram, which can then 1e eBecuted.
$#. 8ode the ta+le61 1tatement 'or a 1in4le level 're<uency/
A; #roc freq data.li1.dataset=
ta1le !ar=Ihere you can mention sin-le !aria1le of multiple !aria1les seperated
1y space to -et sin-le frequency=
run=
$= . 0hat i1 the main di2erence +et&een rename and la+el/
A; +. 0a1el is -lo1al and rename is local i.e., la1el statement can 1e used either
in proc or data step where as rename should 1e used only in data step. *. /f we
rename a !aria1le, old name will 1e lost 1ut if we la1el a !aria1le its short name
8old name; eBists alon- with its descripti!e name.
$9 . 0hat i1 Enterpri1e .uide/ 0hat i1 the u1e o' it/
A; /t is an approach to import teBt 3les with SAS 8/t comes free with Base SAS
!ersion (.0;
50 . 0hat other 9A9 'eature1 do you u1e 'or error trappin4 and data
validation/
?hat are the !alidation tools in SAS@
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
++
SAS Faqs
www.arundathiinfotech.com
A; For dataset, Fata set name<de1u-Fata set, name<stmtchk
For macros, 6ptions,mprint mlo-ic sym1ol-en.
5" . Ho& can you put a ItraceI in your pro4ram/
A; 6FS 2race 6$, 6FS 2race 6FF the trace records.
5!. 0hat i1 the u1e o' Proc 9Jl/
A6 !"#$ FL is a powerful tool in A, which com,ines the functionality of data and proc steps.
!"#$ FL can sort, summariGe, su,set, Eoin 5merge6, and concatenate datasets, create new &aria,les,
and print the results or create a new dataset all in one stepH !"#$ FL uses fewer resources when
compard to that of data and proc steps. To Eoin files in !"#$ FL it does not reBuire to sort the data
prior to merging, which is must, is data merge.
.#. What is SAS )!A+C?
A6 A29"A!- software creates and deli&ers accurate, high@impact &isuals that ena,le decision
makers to gain a Buick understanding of critical ,usiness issues.
.&. Wh1 is a ST,+ statement needed for the point;option on a ST statement?
A6 4hen you use the !#+NT8 option, you must include a T#! statement to stop DATA step
processing, programming logic that checks for an in&alid &alue of the !#+NT8 &aria,le, or (oth.
(ecause !#+NT8 reads only those o,ser&ations that are specified in the D# statement, Acannot
read an end@of@file indicator as it would if the file were ,eing read seBuentially. (ecause reading an
end@of@file indicator ends a DATA step automatically, failure to su,stitute another means of ending the
DATA step when you use !#+NT8 can cause the DATA step to go into a continuous loop.
... WCAT 'S A SAS DAT?
A date is uniBue within A programming. +t is neither a character &alue nor a typical numeric. +t is a
special case of a numeric &aria,le. +n other words, a A date is a special representation of a calendar
date. Unlike dates in many other languages, A has a specific numeric &alue assigned to each day.
The starting point for all A dates is Ianuary ?st, ?JKC and is represented as day Gero 5C6. All
pre&ious and su,seBuent dates are represented with numeric &alues plus 516 or minus 5@6 from this
starting point. The simplicity of the approach is there will ne&er ,e a point in the past 5since the start
of the 9regorian calendar6 or future that cannot ,e represented ,y a num,er.
./. What is DATAL'NS Statement.
The DATAL+N% statement is the last statement in the DATA step and immediately precedes the first
data line. Use a null statement 5a single semicolon6 to indicate the end of the input data.
*ou can use only one DATAL+N% statement in a DATA step. Use separate DATA steps to enter
multiple sets of data.
5# . 0hy 1ame macro varia+le cannot +e u1ed in the 1ame data 1tep/
!en thou-h we ha!e created macro !aria1le usin- the 5A00 S>4#A2 1ut the
same macro !aria1le cannot 1e used in the same data step. 2he reason 1ehind
this is, macro code is compiled and eBecuted 1efore the data step code compiles
and eBecutes. So macro !aria1le created 1y the 5A00 S>4#A2 cannot a!aila1le
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
+*
SAS Faqs
www.arundathiinfotech.com
for the data step 1ecause macro !aria1le compilation time occurs after or in the
middle of the eBecution of the Fata Step code.
8/f a case arises where you ha!e to access the same macro !aria1le inside
the data step, you can certainly do... 1y usin- two diN.. macro functions
called 7S60K or S>4M2;
5#. 0hat are Advanta4e1 o' 8AHH 9K,P:;? over 8AHH 9K,P:;/
Call Symput:
Ase 5A00 S>4#A2 is you need to assi-n a data step !alue to a macro
!aria1le.
Syntax: Call Symput (Macro variable, character value)
2he 3rst ar-ument to the Symput routine is the name of the macro
!aria1le to 1e assi-ned to the !alue from the second ar-ument.
2he second ar-ument is the character !alue that will 1e assi-ned to the
macro !aria1le.
2he second ar-ument need to 1e always a character !alue or if a numeric
!alue is to 1e used it should con!ert 3rst into character !aria1le 1efore
assi-nin- it to macro !aria1le. /t may lead to pro1lems, if you donSt do the
con!ersion from numeric to character. /n this case, SAS automatically
con!erts numeric !alue of the !aria1le to character !alue 1efore assi-nin-
it to macro !aria1le and prints a messa-e in the 06M sayin- that
con!ersion happened.
B+. call symput8PcountP,count;=
B*. call symput8PcountP,strip8put8count,=.;;;=
B). call symput8PcountP,left8put8count,=.;;;=
L3. What happens when +!,C +!'NT or a DATA step is fed =ero o0servations?
A: +n ,oth situations the ,eha&ior is like that of !"#$ FL. +f you run
PROC PRINT DATA=preteen;
WHERE age=10;
RUN;
.5. Names 3ess "r1pti" than u9 and m9 wou3d ma<e thin-s easier to fo33ow.
The mnemonic intent 5not e.plained in the ,ook6 is ;U; for ;uniBue; 5that is, keys which do
not repeat6 and ;); for ;multiple; 5keys which do repeat6.
/: . >a"t31 how "an the missin- va3ues 0e rep3a"ed with =eroes?
A: Use the $#AL%$% function, with the su,Buery as the first argument and Gero as the
second.
/9. Shou3dnDt the ST statement in the se"ond DATA step on the pa-e 0e ST )DS_Demo?
Simi3ar31@ shou3dnDt the se"ond C!AT TAEL on p. 2:2 0e F!,$ )DS_Demo?
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
+)
SAS Faqs
www.arundathiinfotech.com
A: +t doesnDt matter. The 9D 5generation data sets6 feature is a,out naming and referencing
data sets, not a,out the structure and content of those data sets. There is no reBuirement that
the N1?st generation ,e deri&ed from the Nth.
/2. Wh1 is the "ode to "reate A!!'(ALS and D+A!TU!S not shown?
A: >rom the authorDs files:
63 .What is the difference between compiler and interpreter? Give any one example
(software product) that act as an interpreter?
(oth are similar as they achie&e similar purposes, ,ut inherently different as to how they achie&e that
purpose. The interpreter translates instructions one at a time, and then e.ecutes those instructions
immediately. $ompiled code takes programs 5source6 written in A programming language, and
then ultimately translates it into o,Eect code or machine language. $ompiled code does the work much
more efficiently, ,ecause it produces a complete machine language program, which can then ,e
e.ecuted.
/# What is +!,C CD'SC?
+t is new A procedure that is a&aila,le as a hot fi. for A 3.M &ersion and comes as a part
with
A J.?.N &ersion. !"#$ $D+$ is a procedure that allows us to import 5and e.port /)L
files that
are compliant with the $D+$ #D) &ersion ?.M schema.
/&. T$+LAT pro"edure
customiGes #D output for an entire A Eo, or a single #D output o,Eect. ee A
#utput Deli&ery ystem UserDs 9uide for details.
/.. T'$+L,T pro"edure
produces plots of one or more &aria,les o&er time inter&als.
//.T!ANS+,S pro"edure
transposes a data set that changes o,ser&ations into &aria,les and &ice &ersa.
/2.T!ANTAE pro"edure
creates, edits, and displays customiGed translation ta,les.
/?. UN'(A!'AT pro"edure
computes descripti&e statistics 5including Buantiles6, confidence inter&als, and ro,ust estimates for
numeric &aria,les. !ro&ides detail on the distri,ution of numeric &aria,les, which include tests for
normality, plots to illustrate the distri,ution, freBuency ta,les, and tests of location.
/5 A++ND pro"edure
adds o,ser&ations from one A data set to the end of another A data set.
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
+&
SAS Faqs
www.arundathiinfotech.com
2:. E$D+ pro"edure
in&okes a ()D! program to analyGe data in a A data set. ee the A documentation for your
operating en&ironment for more information.
29. CALNDA! pro"edure
displays data from a A data set in a monthly calendar format. !"#$ $AL%NDA" can display
holidays in the month, schedule tasks, and process data for multiple calendars with work schedules
that &ary.
72. CATAL! proced"re
manages entries in A catalogs. !"#$ $ATAL#9 is an interacti&e, non windowing procedure that
ena,les you to display the contents of a catalog, copy an entire catalog or specific entries in a catalog,
and rename, e.change, or delete entries in a catalog.
2#. CCA!T pro"edure
produces &ertical and horiGontal ,ar charts, ,lock charts, pie charts, and star charts. These charts
pro&ide a Buick &isual representation of the &alues of a single &aria,le or se&eral &aria,les. !"#$
$-A"T can also display a statistic associated with the &alues.
2&. C'$+,!T pro"edure
restores a transport file created ,y the $!#"T procedure to its original form 5a A data li,rary,
catalog, or data set6 in the format appropriate to the operating en&ironment. $oupled with the $!#"T
procedure, !"#$ $+)!#"T ena,les you to mo&e A data li,raries, catalogs, and data sets from
one operating en&ironment to another.
2.. C,$+A! pro"edure
compares the contents of two A data sets. *ou can also use !"#$ $#)!A"% to compare the
&alues of different &aria,les within a single data set. !"#$ $#)!A"% produces a &ariety of reports
on the comparisons that it performs.
2/. C,NTNTS pro"edure
prints descriptions of the contents of one or more files in a A data li,rary.
22. C,N(!T pro"edure
con&erts ()D! system files, #+"+ system files, and ! porta,le files to A data sets. ee the
A documentation for your operating en&ironment for more information.
2?. C,+% pro"edure
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
+5
SAS Faqs
www.arundathiinfotech.com
copies an entire A data li,rary or specific mem,ers of the li,rary. *ou can limit processing to
specific types of li,rary mem,ers.
25. C,!! pro"edure
computes !earson product@moment and weighted product@moment correlation coefficients ,etween
&aria,les and descripti&e statistics for these &aria,les. +n addition, !"#$ $#"" can compute three
nonparametric measures of association 5pearmanDs rank@order correlation, OendallDs tau@,, and
-oeffdingDs measure of dependence, D6, partial correlations 5!earsonDs partial correlation, pearmanDs
partial rank@order correlation, and OendallDs partial tau@,6, and $ron,achDs coefficient alpha.
#$. C%&T proced"re
writes A data li,raries, data sets, and catalogs in a special format called a transport file. $oupled
with the $+)!#"T procedure, !"#$ $!#"T ena,les you to mo&e A li,raries, data sets, and
catalogs from one operating en&ironment to another.
?9. C(2('W pro"edure
con&erts A2A$$% &iew descriptors to !"#$ FL &iews. tarting in =ersion J, con&ersion of
A2A$$% &iew descriptors to !"#$ FL &iews is recommended ,ecause !"#$ FL &iews are
platform independent and ena,le you to use the L+(NA)% statement.
?2. DATASTS pro"edure
lists, copies, renames, and deletes A files and A generation groups, manages inde.es, and
appends A data sets in a A data li,rary. The procedure pro&ides all the capa,ilities of the
A!!%ND, $#NT%NT, and $#!* procedures. *ou can also modify &aria,les within data sets,
manage data set attri,utes, such as la,els and passwords, or create and delete integrity constraints.
?#. D,CU$NT pro"edure
manipulates procedure output that is stored in #D documents. !"#$ D#$U)%NT ena,les a user to
,rowse and edit output o,Eects and hierarchies, and to replay them to any supported #D output
format..
?&. *+L,D pro"edure
produces o&ersiGed printing of te.t to generate displays such as posters, flip charts, and header pages.
?.. *+,!T pro"edure
reads data from a A data set and writes it to an e.ternal data source.
?/. F,!$AT pro"edure
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
+6
SAS Faqs
www.arundathiinfotech.com
creates user@defined informats and formats for character or numeric &aria,les. !"#$ >#")AT also
prints the contents of a format li,rary, creates a control data set to write other informats or formats,
and reads a control data set to create informats or formats.
?2. F,!$S pro"edure
produces la,els for en&elopes, mailing la,els, e.ternal tape la,els, file cards, and other printer forms
that ha&e a regular pattern.
##. '&E( proced"re
produces one@way to n@way freBuency ta,les and reports freBuency counts. !"#$ >"%F can
compute chi@sBuare tests for one@way to n@way ta,les, tests and measures of association and of
agreement for two@way to n@way cross@ta,ulation ta,les, risks and risk difference for MPM ta,les,
trends tests, and $ochran@)antel@-aensGel statistics. *ou can also create output data sets.
?5. FSL'ST pro"edure
displays the contents of an e.ternal file or copies te.t from an e.ternal file to the A Te.t %ditor.
5:. '$+,!T pro"edure
reads data from an e.ternal data source and writes them to a A data set.
59. $ANS pro"edure
computes descripti&e statistics for numeric &aria,les across all o,ser&ations and within groups of
o,ser&ations. *ou can also create an output data set that contains specific statistics and identifies
minimum and ma.imum &alues for groups of o,ser&ations.
52. ,+T',NS pro"edure
lists the current &alues of all A system options.
5#. ,+TL,AD pro"edure
reads A system option settings from the A registry or a A data set, and puts them into effect.
5&. ,+TSA( pro"edure
sa&es A system option settings to the A registry or a A data set.
5.. +DS pro"edure
lists, deletes, and renames the mem,ers of a partitioned data set. ee the A documentation for your
operating en&ironment for more information.
5/. +DSC,+% pro"edure
copies partitioned data sets from disk to tape, disk to disk, tape to tape, or tape to disk. ee the A
documentation for your operating en&ironment for more information.
52. +L,T pro"edure
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
+'
SAS Faqs
www.arundathiinfotech.com
produces scatter plots that graph one &aria,le against another. The coordinates of each point on the
plot correspond to the two &aria,lesD &alues in one or more o,ser&ations of the input data set.
5?. +$NU pro"edure
defines menus that you can use in DATA step windows, macro windows, and A2A> windows, or in
any A application that ena,les you to specify customiGed menus.
)). %&I*T proced"re
prints the o,ser&ations in a A data set, using all or some of the &aria,les. !"#$ !"+NT can also
print totals and su,totals for numeric &aria,les.
9::. +!'NTT, pro"edure
defines destinations for A procedure output and the A log.
9:9. +!TDF pro"edure
creates printer definitions for indi&idual A users or all A users.
+$2. %&TE,% proced"re
exports printer definition attributes to a SS data set so that they can be easily replicated
and modified.
+$3. &A*- proced"re
computes ran!s for one or more numeric variables across the observations of a SS data
set. "he ran!s are written to a new SS data set. lternatively# $%&' %() produces
normal scores or other ran! scores.
+$.. &E!IST&/ proced"re
imports re*istry information into the +S,% portion of the SS re*istry.
+$0. &ELEASE proced"re
releases unused space at the end of a dis! data set in the &S-3./ environment. See the
SS documentation for this operatin* environment for more information.
+$1. &E%&T proced"re
combines features of the $%0("# 1,(S# and "2+3", procedures with features of the
4" step in a sin*le report5writin* tool that can produce both detail and summary reports.
+$7. S&T proced"re
sorts observations in a SS data set by one or more variables. $%&' S&%" stores the
resultin* sorted observations in a new SS data set or replaces the ori*inal data set.
+$#. S2&CE proced"re
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
+Q
SAS Faqs
www.arundathiinfotech.com
provides an easy way to bac! up and process source library data sets. See the SS
documentation for your operatin* environment for more information.
+$). S(L proced"re
implements a subset of the Structured 6uery 3an*ua*e (S63) for use in SS. S63 is a
standardi7ed# widely used lan*ua*e that retrieves and updates data in SS data sets# S63
views# and 421S tables# as well as views based on those tables. $%&' S63 can also
create tables and views# summaries# statistics# and reports and perform utility functions such
as sortin* and concatenatin*.
++$ STA*DA&D proced"re
standardi7es some or all of the variables in a SS data set to a *iven mean and standard
deviation and produces a new SS data set that contains the standardi7ed values.
+++. S233A&/ proced"re
computes descripti&e statistics for the &aria,les in a A data across all o,ser&ations and within
groups of o,ser&ations and outputs the results to a new A data set.
992. TAEULAT pro"edure
displays descripti&e statistics in ta,ular form. The &alue in each ta,le cell is calculated from the
&aria,les and statistics that define the pages, rows, and columns of the ta,le. The statistic associated
with each cell is calculated on &alues from all o,ser&ations in that category. *ou can write the results
to a A data set.
99#. TA+C,+% pro"edure
copies an entire tape &olume or files from one or more tape &olumes to one output tape &olume. ee
the A documentation for your operating en&ironment for more information.
99&. TA+LAEL pro"edure
lists the la,el information of an +() standard@la,eled tape &olume under the #2NJC en&ironment.
ee the A documentation for this operating en&ironment for more information.
99.. SU$ or G
Adding num,ers with the U) function pro&ides the same result that you get with the 1 numeric
operator. >or e.ample, SUM(8, 4, ! pro&ides the same result as 8 " 4 " . ometimes,
though, you prefer to use the U) function, and at other times, the 1 operator. As you e.plain this
distinction, you can show that you understand:
99/. !UN statement p3a"ement
The output of a program may ,e different ,ased on whether a "UN statement comes ,efore or after a
glo,al statement such as an #!T+#N or T+TL% statement. +f you are aware of this issue, it shows
that you ha&e written A programs that ha&e more than the simplest of o,Eecti&es. At the same time,
your comments on this su,Eect can also show that you know:
992 . Statisti"sB fun"tions vs. pro" steps
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
+(
SAS Faqs
www.arundathiinfotech.com
$omputing a statistic with a function, such as the )%AN function, is not e.actly the same as
computing the same statistic with a procedure, such as the UN+=A"+AT% procedure. As you e.plain
this distinction, you show that you understand:
99?. WC! vs. 'F
ometimes, it makes no difference whether you use a 4-%"% statement or a su,setting +> statement.
ometimes it makes a ,ig difference. +n e.plaining this distinction, you ha&e the opportunity to
discuss:
995. De0u--er
)ost A programmers ne&er use the data step de,ugger, so Buestions a,out it are pro,a,ly intended
to determine how you feel a,out de,ugging Q does the de,ugging process ,ug you, or is de,ugging
one of the most essential things you do as a programmer7
92:. 'nformats vs. formats
+f you appreciate the distinction ,etween informats and formats, it shows that:
*ou can focus on details
+t doesnRt confuse you that two routines ha&e the same name
*ou ha&e some idea of what is going on when a A program runs
929. T!ANS+,S pro"edure
The T"AN!#% procedure has a few important uses, ,ut Buestions a,out it usually donRt ha&e that
much to do with the procedure itself. The intriguing characteristic of the T"AN!#% procedure is
that input data &alues determine the names of output &aria,les. The implication of this is that if the
data &alues are incorrect, the program could end up with the wrong output &aria,les. +n what other
ways does a program depend on ha&ing &alid or correct data &alues as a starting point7 4hat does it
take to write a program that will run no matter what input data &alues are supplied7
?MM. 'mportant SAS trivia
ome A tri&ia may ,e important to know in a technical inter&iew, e&en though it may ne&er come
up in your actual A programming work.
)%"9% is a data step statement only. There is no )%"9% procedure. S!"#$ )%"9%T is a
mythical construction created years ago ,y "hena eidman, and if you are asked a,out it in a
Eo, inter&iew, it is meant as a trick Buestion.
+t is possi,le to use the )%"9% statement without a (* statement, ,ut this usually occurs ,y
mistake.
A does not pro&ide an easy way to create a procedure in a A program. -owe&er, it is
easy to define informats and formats and use them in the same program. (eginning with A
J.M, the same is true of functions.
The )%AN and U))A"* procedures are identical e.cept for the defaults for the !"+NT
option and =A" statement.
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
*0
SAS Faqs
www.arundathiinfotech.com
)uch of the synta. of the TA(ULAT% procedure is essentially the same of that of the
U))A"* procedure.
$A"D is another name for DATAL+N% 5or &ice &ersa6.
SDATA _NULL_T is commonly used as a code word to refer to data step programming that
creates print output or te.t data files.
The program data &ector 5!D=6 is a logical ,lock of data that contains the &aria,les used in a
data step or proc step. =aria,les are added to the program data &ector in order of appearance,
and this is what determines their position 5or &aria,le num,er6 attri,ute.
inteD
(n'ormation:
2he /$2$U function increments a date, time, or datetime !alue 1y inter!als
such as FA>, ?E, H27, and 4/$A2. 2he increment is 1ased on a
startin- date, time, or datetime !alue, and on the num1er of time inter!als
that you specify.
2he /$2$U function returns the SAS date !alue for the 1e-innin- date,
time, or datetime !alue of the inter!al that you specify in the start%from
ar-ument. 82o con!ert the SAS date !alue to a calendar date, use any !alid
SAS date format, such as the FA2(. format.;
"!. 9yntaD Error1
SyntaB errors occur when pro-ram statements do not conform to the rules of the
SAS lan-ua-e. "ere are some eBamples of syntaB errors,
misspelled SAS keyword
unmatched quotation marks
missin- a semicolon
in!alid statement option
in!alid data set option.
?hen SAS encounters a syntaB error, it 3rst attempts to correct the error 1y
attemptin- to interpret what you mean. 2hen SAS continues processin- your
pro-ram 1ased on its assumptions. /f SAS cannot correct the error, it prints an
error messa-e to the lo-.
"!! Ho& can ( 1ee the num+er o' mi11in4 value1 and pattern1 o'
mi11in4 value1 in my data Fle/
ometimes, a data set may ha&e ;holes; in them, i.e., missing &alues. ome statistical procedures such
as regression analysis will not work as well, or at all, on data set with missing &alues. The
o,ser&ations with missing &alues ha&e to ,e either deleted or the missing &alues ha&e to ,e su,stituted
in order for a statistical procedure to produce meaningful results. Thus we may want to know the
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
*+
SAS Faqs
www.arundathiinfotech.com
num,er of missing &alues and the distri,ution of those missing &alues so we ha&e a ,etter idea on
what to do with the o,ser&ations with missing &alues. LetDs look at the following data set.
92#. Num0er of missin- va3ues in ea"h o0servation and its distri0ution
4e can also look at the distri,ution of missing &alues across o,ser&ations. >or e.ample &aria,le
numiss created ,elow is the num,er of missing &alues across each o,ser&ation. Looking at its
freBuency ta,le we know that there are four o,ser&ations with no missing &alues, nine o,ser&ations
with one missing &alues, one o,ser&ation with two missing &alues and one o,ser&ation with three
missing &alues. +f we are willing to su,stitute one missing &alue per o,ser&ation, we will ,e a,le to
reclaim nine o,ser&ations ,ack to get a &alid data set that is ?N2?L 8 3UV of the siGe of the original
one.
92&. Cow do ' disp3a1 information for a33 the SAS datasets in a dire"tor1?
LetDs say that we ha&e a num,er of A data files in a directory and we need to know the num,er of
o,ser&ations and the num,er of &aria,les in each data set. #f course, we can always use proc contents
on each of the data set, ,ut it can get tedious and the output will get too long really Buickly.
There is an easy solution with the A data file sashelp.&ta,le that A creates and updates during an
acti&e A session.
-ere is an e.ample. LetDs say we ha&e a directory called c:WdataWdissertation and it contains many A
files. -ere is the sas code to display all the A files in the directory with information on the num,er
of o,ser&ations and the num,er of &aria,les.
92.. Cow do ' read in a "hara"ter varia+le &ith varyin4 len4th in a 1pace
delimited data1et/
This >AF page demonstrates the use of traditional methods and introduces A special characters for
reading in 5messy6 data with a character &aria,le of &arying length.
126.When the character variable contains only a single word
This half of the page shows how to read in a character &aria,le with a single word with &arying length
when the dataset is space delimited. >or our e.ample we ha&e a hypothetical we,site dataset with the
following &aria,les: age of page 5a-e6, the url 5site6 and the num,er of hits the site recei&ed 5hits6.
4e start ,y reading in the dataset where our character &aria,le, site, is read in with the default
character format gi&en ,y H.
922 Cow do ' spe"if1 t1pes of missin- va3ues?
4hen a data file has missing &alues, sometimes we may want to ,e a,le to distinguish ,etween
different types of missing &alues. >or e.ample, we can ha&e missing &alues ,ecause of non@response
or missing &alues ,ecause of in&alid data entry. The e.amples here are related to this issue.
>amp3e 9B Spe"if1in- t1pes of missin- va3ues in a data set
+n A, we can use letters A@: and underscore ;_; to indicate the type of missing &alues.
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
**
SAS Faqs
www.arundathiinfotech.com
+n the e.ample ,elow, &aria,le fema3e has &alue @JJJ indicating that the su,Eect refused to answer the
Buestion and &alue @JJ indicating a data entry error. +t is the same with &aria,le ses. The first code
fragment hard codes the changes, the second does the operation in an array.
data test9I
input s"ore fema3e ses I
data3inesI
./ 9 9
/2 9 2
2# : #
/2 J555 9
.2 : 9
./ J55 2
.2 9 J555
I
runI
Khard "odeI
data test9aI
set test9I
if fema3e ; J555 then fema3e;.aI
if fema3e ; J55 then fema3e ; .0I
if ses ; J555 then ses ; .aI
runI
pro" print data ; test9aI
runI
O#$ $%&re 'e(a)e $e$
1 *+ 1 1
, +, 1 ,
- 0
4 +- A 1
* *- 0 1
+ *+ . ,
- *- 1 A
*using the array;
data test1b;
set test1;
array miss(2) female ses;
do i = 1 to 2;
if miss(i) = -999 then miss(i) =.a;
if miss(i) = -99 then miss(i) =.b;
end;
drop i;
run;
proc print data = test1b;
run;
O#$ $%&re 'e(a)e $e$
1 *+ 1 1
, +, 1 ,
- 0
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
*)
SAS Faqs
www.arundathiinfotech.com
4 +- A 1
* *- 0 1
+ *+ . ,
- *- 1 A
4e should notice that when A prints a special missing &alue, it prints only the letter or underscore,
not the dot ;.;.
92? Cow do ' write out a fi3e that uses "ommas@ ta0s or spa"es as de3imiters to separate
varia03es in SAS?
+t is Buite easy to read a file that uses a comma as a delimiter using pro" import in A. There are
two slightly different ways of reading a comma delimited file using pro" import. +n A, a comma
delimited file can ,e considered as a special type of e.ternal file with special file e.tension .cs&,
which stands for comma@separated@&aria,les. 4e show here the first sample program making use of
this feature. LetDs say we ha&e following data stored in a file called "omma."sv.
925 Cow do ' read raw data via FT+ in SAS?
A has the a,ility to read raw data directly from >T! ser&ers. Normally, you would use >T! to
download the data to your local computer and then use A to read the data stored on your local
computer. A allows you to ,ypass the >T! step and read the data directly from the other computer
&ia >T! without the intermediate step of downloading the raw data file to your computer. #f course,
this assumes that you can reach the computer &ia the internet at the time you run your A program.
The program ,elow illustrates how to do this. After the fi3ename in you put ftp to tell A to access
the data &ia >T!. After that, you supply the name of the file 5in this case D-pa.t>tD. 3re"3; is used to
specify the width of your data. (e sure to choose a &alue that is at least as wide as your widest record.
"d; is used to specify the directory from where the file is stored. host; is used to specify the name of
the site to which you want to >T!. user; is used to pro&ide your userid 5or anon1mous if connecting
&ia anonymous >T!6. pass; is used to supply your password 5or your email address if connecting &ia
anonymous >T!6.
9#: DL$;
The d3m; option can ,e used to specify the delimiter that separates the &aria,les in your raw data file.
>or e.ample, d3m;D@Dindicates a comma is the delimiter 5e.g., a comma separated file, .cs& file6. #r,
d3m;D:5D> indicates that ta,s are used to separate your &aria,les 5e.g., a ta, separated file6.
9#9 DSD
The dsd option has M functions. >irst, it recogniGes two consecuti&e delimiters as a missing &alue. >or
e.ample, if your file contained the line 2:@#:@@.: A will treat this as 2: #: .: ,ut with the the dsd
option A will treat it as 2: #: . .: , which is pro,a,ly what you intended. econd, it allows you to
include the delimiter within Buoted strongs. >or e.ample, you would want to use the dsd option if you
had a comma separated file and your data included &alues like ;9eorge (ush, Ir.;. 4ith the dsd
option, A will recogniGe that the comma in ;9eorge (ush, Ir.; is part of the name, and not a
separator indicating a new &aria,le.
9#2 F'!ST,ES;
This option tells A what on what line you want it to start reading your raw data file. +f the first
record5s6 contains header information such as &aria,le names, then set firsto0s;n where n is the
record num,er where the data actually ,egin. >or e.ample, if you are reading a comma separated file
or a ta, separated file that has the &aria,le names on the first line, then use firsto0s;2 to tell A to
,egin reading at the second line 5so it will ignore the first line with the names of the &aria,les6.
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
*&
SAS Faqs
www.arundathiinfotech.com
9## $'SS,(!
This option pre&ents A from going to a new input line if it does not find &alues for all of the
&aria,les in the current line of data. >or e.ample, you may ,e reading a space delimited file and that is
supposed to ha&e ?C &alues per line, ,ut one of the line had only J &alues. 4ithout the missover
option, A will look for the ?Cth &alue on the ne.t line of data. +f your data is supposed to only ha&e
one o,ser&ation for each line of raw data, then this could cause errors throughout the rest of your data
file. +f you ha&e a raw data file that has one record per line, this option is a prudent method of trying
to keep such errors from cascading through the rest of your data file.
9#& ,ES;
+ndicates which line in your raw data file should ,e treated as the last record to ,e read ,y A. This
is a good option to use for testing your program. >or e.ample, you might use o0s;9:: to Eust read in
the first ?CC lines of data while you are testing your program. 4hen you want to read the entire file,
you can remo&e the o0s; option entirely.
A typical infi3e statement for reading a comma delimited file that contains the &aria,le names in the
first line of data would ,e:
'NF'L Ltest.t>tL DL$;D@D DSD $'SS,(! F'!ST,ES;2 I
9#.. Cow "an ' "reate an enumeration varia03e 01 -roups?
There are occasions, especially with sur&ey data, when you need to create an enumeration 5also called
a counting or identification6 &aria,le that starts at one for each group in your data. >or e.ample,
suppose that you ha&e test scores for students in a class. *ou may need to create a &aria,le that counts
all of the males in the class, and then starts at one and counts all of the females in the class. LetDs look
at a small data set and see how this can ,e easily done.
9#/. data "omponent
is a form, similar to a A data set, that contains the results 5num,ers and characters6 of a
DATA step or !"#$ step that supports #D.
9#2. ta03e definition
is a set of instructions that descri,es how to format the data. This description includes ,ut is
not limited to
the order of the columns
te.t and order of column headings
formats for data
font siGes and font faces.
9#?. output o0Me"t
is an o,Eect that contains ,oth the results of a DATA step or !"#$ step and information
a,out how to format the results. An output o,Eect has a name, la,el, and path. >or e.ample,
the (asic tatistical )easurement ta,le generated from the UN+=A"+AT% procedure is an
output o,Eect. +t contains the data component and formatted presentation of the mean,
median, mode, standard de&iation, &ariance, range, and interBuartile range.
NoteB Although many output o,Eects include formatting instructions, not all of them do. +n
some cases the output o,Eect consists of only the data component.
9&: . ,DS destinations
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
*5
SAS Faqs
www.arundathiinfotech.com
are designations that produce specific types of output. #D supports a num,er of
destinations, including the following:
L+T+N9
produces traditional A output 5monospace format6.
)arkup Languages
produce A output that is formatted using one of many different markup languages such as
-T)L 5-yperte.t )arkup Language6, /)L 5%.tensi,le )arkup Language6, and LaTe/
that you can access with a we, ,rowser. A supplies many markup languages for you to
use ranging from D#$(##O to T"#>>. *ou can specify a markup language that A
supplies or create one of your own and store it as a user@defined markup language.
9&9. D,CU$NT
produces a hierarchy of output o,Eects that ena,les you to render multiple #D output
formats without rerunning a !"#$ or DATA step and gi&es you more control o&er the
structure of the output.
9&2. ,UT+UT
produces a A data set.
$rinter 8amily
produces output that is formatted for a hi*h5resolution printer such as a $ost Script
($S)# $48# or $'3 file.
+.3. !TF
produces output that is formatted for use with )icrosoft 4ord.
9&&. ,DS output
#D output consists of formatted output from any of the #D destinations. >or e.ample,
the #UT!UT destination produces A data sets' the L+T+N9 destination produces listing
output' the -T)L destination produces output that is formatted in -yperte.t )arkup
Language
+.0. 45at Are Ta6le De7initions8 Ta6le Elements8 and Ta6le Attri6"tes?
A ta03e definition descri,es how to render the output for a ta,ular output o,Eect. 5)ost #D output is
ta,ular.6 A ta,le definition determines the order of column headers and the order of &aria,les, as well
the o&erall look of the output o,Eect that uses it.
+n addition to the parts of the ta,le definition that order the headers and columns, each ta,le definition
contains or references ta03e e3ements. A ta,le element is a collection of ta,le attri,utes that apply to a
particular header, footer, or column. Typically, a ta03e attri0ute specifies something a,out the data
rather than a,out its presentation. >or e.ample, >#")AT specifies the A format, such as the
num,er of decimal places. -owe&er, some ta,le attri,utes descri,e presentation aspects of the data,
such as how many ,lank characters to place ,etween columns.
NoteB The attri,utes of ta,le definitions that control the presentation of the data ha&e no effect on
output o,Eects that go to the L+T+N9 or #UT!UT destination. -owe&er, the attri,utes that control
the structure of the ta,le and the data &alues do affect listing output.
9&/ . What Are St13e Definitions@ St13e 3ements@ and St13e Attri0utes?
To customiGe the output at the le&el of your entire output stream in a A session, you specify a style
definition. A st13e definition descri,es how to render the presentation aspects 5color, font face, font
siGe, and so on6 of the entire A output. A style definition determines the o&erall look of the
documents that use it.
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
*6
SAS Faqs
www.arundathiinfotech.com
%ach style definition is composed of st13e e3ements. A style element is a collection of style attri,utes
that apply to a particular part of the output. >or e.ample, a style element may contain instructions for
the presentation of column headers, or for the presentation of the data inside the cells. tyle elements
may also specify default colors and fonts for output that uses the style definition.
%ach st13e attri0ute specifies a &alue for one aspect of the presentation. >or e.ample, the
(A$O9"#UND8 attri,ute specifies the color for the ,ackground of an -T)L ta,le or for a colored
ta,le in printed output. The >#NT_T*L%8 attri,ute specifies whether to use a "oman or an italic
font.
9&2 Cata3o- Con"atenation
The $ATAL#9 procedure supports ,oth implicit and e.plicit concatenation of catalogs. All
statements and options that can ,e used on single 5un concatenated6 catalogs can ,e used on catalog
concatenations.
9&?. $ATCCJ$!)'N)
)atch@merging com,ines o,ser&ations from two or more A data sets into a single o,ser&ation in a
new data set according to the &alues of a common &aria,le. The num,er of o,ser&ations in the new
data set is the sum of the largest num,er of o,ser&ations in each (* group in all data sets. To perform
a match@merge, use the )%"9% statement with a (* statement. (efore you can perform a match@
merge, all data sets must ,e sorted ,y the &aria,les that you specify in the (* statement or they must
ha&e an inde..
9&5 .
U+DA
T
uses o,ser&ations from the transaction data set to change the &alues of corresponding
o,ser&ations from the master data set. *ou must use a (* statement with the U!DAT%
statement ,ecause all o,ser&ations in the transaction data set are keyed to o,ser&ations in
the master data set according to the &alues of the (* &aria,le.
9.:
.$,D'
F%
can replace, delete, and append o,ser&ations in an e.isting data set. Using the )#D+>*
statement can sa&e disk space ,ecause it modifies data in place, without creating a copy of
the data set.
9.9. arra1
is a temporary grouping of A &aria,les that are arranged in a particular order
and identified ,y an arra1Jname. The array e.ists only for the duration of the
current DATA step. The array@name distinguishes it from any other arrays in the
same DATA step' it is not a &aria,le.
9.2. arra1 pro"essin-
is a method that ena,les you to perform the same tasks for a series of related
&aria,les.
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
*'
SAS Faqs
www.arundathiinfotech.com
9.# . arra1 referen"e
is a method to reference the elements of an array.
9.&. oneJdimensiona3 arra1
is a simple grouping of &aria,les that, when processed, results in output that can
,e represented in simple row format.
9... mu3tidimensiona3 arra1
is a more comple. grouping of &aria,les that, when processed, results in output
that could ha&e two or more dimensions, such as columns and rows.
?LK. (asic array processing in&ol&es the following steps:
grouping &aria,les into arrays
selecting a current &aria,le for an action
repeating an action.
?LU. D# 4-+L% and D# UNT+L %.pressions
Arrays are often processed in iterati&e D# loops that use the array reference in a
D# 4-+L% or D# UNT+L e.pression. +n this e.ample, the iterati&e D# loop
processes the elements of the array named T"%ND.
9.?. A permanent SAS data 3i0rar1 is one that resides on the e.ternal storage medium of
your computer and is not deleted when the A session terminates. !ermanent A data
li,raries are stored until you delete them. The li,rary is a&aila,le for processing in
su,seBuent A sessions. 4hen working with files in a permanent A data li,rary, you
generally specify a li,ref as the first part of a two@le&el A filename. The li,ref tells A
where to find or store the file.
9.5. ,peratin- nvironment 'nformationB >iles are specified differently in &arious
operating en&ironments. ee the A documentation for your operating en&ironment for
more information.
?KC. A temporar1 SAS data 3i0rar1 is one that endures only for the current A session
or Eo,. A files that are created during the session or Eo, are held in a special work space
that may or may not ,e an e.ternal storage medium. This work space is generally assigned
the default li,ref 4#"O. >iles in the temporary 4#"O li,rary can ,e used in any DATA
step or A procedure during the A session, ,ut they are typically not a&aila,le for
su,seBuent A sessions. Normally, you specify that data sets ,e stored in or retrie&ed from
this li,rary ,y specifying a one@le&el name. >iles held in the 4#"O li,rary are deleted at
the end of the A session if it ends normally.
There are a num,er of A system options that ena,le you to customiGe the way you name
and work with your permanent and temporary A data li,raries.
?K?. +ntroduction to A ystem Li,raries
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
*Q
SAS Faqs
www.arundathiinfotech.com
>our special A@supplied li,raries pro&ide con&enience, support, and customiGation
capa,ility:
4#"O
U%"
A-%L!
AU%"
?KM. Definition of 4#"O Li,rary
The 4#"O li,rary is the temporary 5scratch6 li,rary that is automatically defined ,y A
at the ,eginning of each A session. The 4#"O li,rary stores two types of temporary
files: those that you create and those that are created internally ,y A as part of normal
processing. Typically, the 4#"O li,rary is deleted at the end of each A session if the
session terminates normally.
?KN . Using the 4#"O Li,rary
To store or retrie&e A files in the 4#"O li,rary, specify a one@le&el name in your A
program statements. The li,ref 4#"O is automatically assigned to these files as a system
default unless you ha&e assigned the U%" li,ref. The following e.amples contain &alid
names for A data sets stored in the 4#"O li,rary:
?KX. #perating %n&ironment +nformation: The 4#"O li,rary is implemented differently
in &arious operating en&ironments. ee the A documentation for your operating
en&ironment for more information.
9/.. !e3ation to the US! Li0rar1
4hile the 4#"O li,rary is designed to hold temporary files used during the current A
session, the U%" li,rary is designed to hold files after the A session is o&er. +f you
associate the li,ref U%" with a A data li,rary, use a one@le&el name to create and access
files that are not deleted at the end of your A session. 4hen A encounters a one@le&el
filename, it looks first in the U%" li,rary, if it has ,een defined, and then it looks in
4#"O. +f you wish to place a file in the U%" li,rary, so that it is not deleted after your
A session is o&er, any single@le&el file goes there ,y default. At that point, if you want to
create a temporary file in 4#"O, you must use a two@le&el name, such as 4#"O.NA)%.
9//. Definition of US! Li0rar1
The U%" li,rary allows you to read, create, and write to files in a A data li,rary other
than 4#"O without specifying a li,ref as part of the A filename. #nce you associate the
li,ref U%" with a A data li,rary, A stores any file with a one@le&el name in that
li,rary. Unlike the 4#"O li,rary, files stored in this li,rary are not deleted ,y A when
the session terminates.
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
*(
SAS Faqs
www.arundathiinfotech.com
9/2. !e3ation to W,!N Li0rar1
The U%" li,ref o&errides the default li,ref 4#"O for one@le&el names. 4hen you refer to
a file ,y a one@le&el name, A looks first for the li,ref U%". +f U%" is assigned to a
A data li,rary, files with one@le&el names are stored there. +f you ha&e not assigned the
li,ref U%" to a li,rary, the files with one@le&el names are stored in the temporary li,rary
4#"O. To refer to A files in the 4#"O li,rary while the U%" li,ref is assigned, you
must specify a two@le&el name with 4#"O as the li,ref. Data files that A creates
internally still go to the 4#"O li,rary.
9/? SASCL+ Li0rar1
%ach A site recei&es the A-%L! li,rary, which contains a group of catalogs and other
files containing information that is used to control &arious aspects of your A session. The
defaults stored in this li,rary are for e&eryone using A at your installation. *our personal
settings are stored in the AU%" li,rary, which is discussed later in this section.
+f A products other than ,ase A are installed at your site, the A-%L! li,rary
contains catalogs that are used ,y those products. +n many instances, the defaults in this
li,rary are tailored to your site ,y your A oftware "epresentati&e. *ou can list the
catalogs stored at your site ,y using one of the file management utilities discussed later in
this section.
9/5 . SASUS! Li0rar1
The AU%" li,rary contains A catalogs that ena,le you to tailor features of A for
your needs. +f the defaults in the A-%L! li,rary are not suita,le for your applications,
you can modify them and store your personaliGed defaults in your AU%" li,rary. >or
e.ample, in ,ase A, you can store your own defaults for function key settings or window
attri,utes in a personal profile catalog named AU%".!"#>+L%.
A assigns the AU%" li,rary during system initialiGation, according to the
information supplied ,y the AU%" system option.
A system option called "AU%" allows the system administrator to control the mode of
access to the AU%" li,rary at installations that ha&e one AU%" li,rary for all users
and that want to pre&ent users from modifying it.
92: Whi"h date fun"tions advan"es a date time or dateOtime va3ue 01 a -iven interva3?
A6 +NTN/.
929 Cow we "an "a33 ma"ros with in data step?
A6 4e can call the macro with $ALL*)!UT
922 'n the f3ow of DATA step pro"essin-@ what is the first a"tion in a t1pi"a3 DATA
Step?
A6 4hen you su,mit a DATA step, A processes the DATA step and then creates a new
A data set.5 creation of input ,uffer and !D=6$ompilation !hase%.ecution !hase
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
)0
SAS Faqs
www.arundathiinfotech.com
92# Cow do u identif1 a ma"ro varia03e
A6 Ampersand 5Y6
92& What are SASOACCSS and SASOC,NNCT?
A6 A2Access only process through the data,ases like #racle, FL@ser&er, )s@Access etc.
A2$onnect only use er&er connection.
92. Cow "ou3d 1ou -enerate test data with no input data?
92/ What is the one statement to set the "riteria of data that "an 0e "oded in an1
step?
A6 #!T+#N tatement, La,el statement, Oeep 2 Drop statements.
922 What is the purpose of usin- the N;+S option?
A6 The N8! option creates a ,uffer in memory which is large enough to store !A9%+:%
5!6 lines and ena,les a page to ,e formatted randomly prior to it ,eing printed.
92? What are the s"ru00in- pro"edures in SAS?
A6 !roc ort with nodupkey option, ,ecause it will eliminate the duplicate &alues.
925 What has 0een 1our most "ommon pro-rammin- mista<e?
+ remem,er )issing semicolon and not checking log after su,mitting program, Not using
de,ugging techniBues and not using >s&iew option &igorously are my common
programming errors + made when + started learning A and in my initial proEects.
9?: Cave 1ou ever had to fo33ow S,+s or pro-rammin- -uide3ines?
#! descri,es the process to assure that standard coding acti&ities, which produce ta,les,
listings and graphs, functions and2or edit checks, are conducted in accordance with industry
standards are appropriately documented.
$heck out the how the #! looks Like:
https:2...2workspaces2$T)2)eetings2+9s2(est_!ractices2MCCK_#!s2+TCCL_#!_tanda
rd_!rogramming.pdf
+t is normally used whene&er new programs are reBuired or e.isting programs reBuired
some modification during the set@up, conduct, and2or reporting clinical trial data.
9?9 Name severa3 wa1s to a"hieve effi"ien"1 in 1our pro-ram. >p3ain tradeJoffs.
%fficiency and performance strategies can ,e classified into L different areas.
< $!U time
< Data torage
< %lapsed time
< +nput2#utput
< )emory
$!U Time and %lapsed Time@ (ase line measurements
9?2 What other SAS produ"ts have 1ou used and "onsider 1ourse3f profi"ient in usin-?
Data _NULL_ statement, !roc )eans, !roc "eport, !roc ta,ulate, !roc freB and !roc print, !roc
Uni&ariate etc.
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
)+
SAS Faqs
www.arundathiinfotech.com
9?# What is the si-nifi"an"e of the D,FD in *;SU$ 6,F a9Ja&@ a/@ a58I
+f donRt use the #> function it might not ,e interpreted as we e.pect. >or e.ample the function a,o&e
calculates the sum of a? minus aX plus aK and aJ and not the whole sum of a? to aX Y aK and aJ. +t is
true for mean option also.
9?& What do the +UT and 'N+UT fun"tions do?
+N!UT function con&erts character data &alues to numeric &alues.
!UT function con&erts numeric &alues to character &alues.
%/: for +N!UT: +N!UT 5source, informat6
>or !UT: !UT 5source, format6
Note that +N!UT function reBuires +N>#")AT and !UT function reBuires >#")AT.
+f we omit the +N!UT or the !UT function during the data con&ersion, A will detect the
mismatched &aria,les and will try an automatic character@to@numeric or numeric@to@character
con&ersion. (ut sometimes this doesnRt work ,ecause Z sign pre&ents such con&ersion. Therefore it is
always ad&isa,le to include +N!UT and !UT functions in your programs when con&ersions occur.
185. Which date function advances a date, time or datetime value by a given
interva3?
+NTN/: +NTN/ function ad&ances a date, time, or datetime &alue ,y a gi&en inter&al, and returns a
date, time, or datetime &alue.
%.: +NTN/5inter&al,start@from,num,er@of@increments,alignment6
9?/ 'NTCNB 'NTCN5inter&al,start@of@period,end@of@period6 is an inter&al functioncounts the
num,er of inter&als ,etween two gi&e A dates, Time and2or datetime.
DAT%T+)% 56 returns the current date and time of day.
DATD+> 5sdate,edate,,asis6: returns the num,er of days ,etween two dates.
9?2 What do the $,D and 'NT fun"tion do? What do the +AD and D'$ fun"tions do?
$,D: )odulo is a constant or numeric &aria,le, the function returns the reminder after numeric
&alue di&ided ,y modulo.
'NT: +t returns the integer portion of a numeric &alue truncating the decimal portion.
!AD: it pads each record with ,lanks so that all data lines ha&e the same length. +t is used in the
+N>+L% statement. +t is useful only when missing data occurs at the end of the record.
$AT/: concatenate character strings, remo&es leading and trailing ,lanks and inserts separators.
$AN: it returns a specified word from a character &alue. can function assigns a length of MCC to
each target &aria,le.
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
)*
SAS Faqs
www.arundathiinfotech.com
U(T": e.tracts a su, string and replaces character &alues.
%.traction of a su,string: )iddleinitial8su,str5middlename,?,?6'
"eplacing character &alues: su,str 5phone,?,N68RXNNR'
+f U(T" function is on the left side of a statement, the function replaces the contents of the
character &aria,le.
T"+): trims the trailing ,lanks from the character &alues.
9??. SCAN vs. SUEST!B
$AN e.tracts words within a &alue that is marked ,y delimiters.
U(T" e.tracts a portion of the &alue ,y stating the specific location. +t is ,est used when we know
the e.act position of the su, string to e.tract from a character &alue.
9?5 Cow mi-ht 1ou use $,D and 'NT on numeri" to mimi" SUEST! on "hara"ter
Strin-s?
The first argument to the )#D function is a numeric, the second is a non@Gero numeric' the result is
the remainder when the integer Buotient of argument@? is di&ided ,y argument@M. The +NT function
takes only one argument and returns the integer portion of an argument, truncating the decimal
portion. Note that the argument can ,e an
e.pression.
DATA N%4 '
A 8 ?MNXLK '
/ 8 +NT5 A2?CCC 6 '
* 8 )#D5 A, ?CCC 6 '
: 8 )#D5 +NT5 A2?CC 6, ?CC 6 '
!UT A8 /8 *8 :8 '
"UN '
A=123456
X=123
Y=456
Z=34
95: 'n A!!A% pro"essin-@ what does the D'$ fun"tion do?
D+): +t is used to return the num,er of elements in the array. 4hen we use Dim function we would
ha&e to re Aspecify the stop &alue of an iterati&e D# statement if u change the dimension of the array.
959 Cow wou3d 1ou determine the num0er of missin- or nonmissin- va3ues in "omputations?
A6To determine the num,er of missing &alues that are e.cluded in a computation, use the N)+
function.
data _null_'
m 8 . ' y 8 X ' G 8 C '
N 8 N5m , y, G6'
N)+ 8 N)+ 5m , y, G6'
run'
The a,o&e program results in N 8 M 5Num,er of non missing &alues6 and N)+ 8 ? 5num,er of
missing &alues6.
Do you need to know if there are any missing &alues7 Iust use:
missing_&alues8)++N95field?,fieldM,fieldN6'
This function simply returns C if there arenDt any or ? if there are missing &alues.
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
))
SAS Faqs
www.arundathiinfotech.com
+f you need to know how many missing &alues you ha&e then use
num_missing8N)+5field?,fieldM,fieldN6'
*ou can also find the num,er of non@missing &alues with non_missing8N 5field?,fieldM,fieldN6'
952 What is the differen"e 0etweenB >;aG0G"GdI and >;SU$ 6of a@ 0@ " @d8I?
+s anyone wondering why you wouldnRt Eust use total8field?1fieldM1fieldN'
>irst, how do you want missing &alues handled7 The U) function returns the sum of non@missing
&alues. +f you choose addition, you will get a missing &alue for the result if any of the fields are
missing. 4hich one is appropriate depends upon your needs. -owe&er, there is an ad&antage to use
the U) function e&en if you want the results to ,e missing. +f you ha&e more than a couple fields,
you can often use shortcuts in writing the field names
+f your fields are not num,ered seBuentially ,ut are stored in the program data &ector together then
you can use:
total8U)5of fielda@@Gfield6'
Iust make sure you remem,er the SofT and the dou,le dashes or your code will run ,ut you wonRt get
your intended results.
)ean is another function where the function will calculate differently than the writing out the formula
if you ha&e missing
&alues.
95# There is a fie3d "ontainin- a date. 't needs to 0e disp3a1ed in the format Lddmon11L if itDs
0efore 952.@ Ldd mon ""11L if itDs after 95?.@ and as DDis"o %earsD if itDs 0etween 952. and 95?..
Cow wou3d 1ou a""omp3ish this in data step "ode? Usin- on31 +!,C F,!$AT.
95& . 'n the fo33owin- DATA step@ what is needed for Dfra"tionD to print to the 3o-?
data _null_'
.8?2N'
if .8.NNNN then put DfractionD'
run'
95.. What is the differen"e 0etween "a3"u3atin- the DmeanD usin- the mean fun"tion and +!,C
$ANS?
A6 (y default !roc )eans calculate the summary statistics like N, )ean, td de&iation, )inimum and
ma.imum, 4here as )ean function compute only the mean &alues.
95/. What are some differen"es 0etween +!,C SU$$A!% and +!,C $ANS?
A6 !roc means ,y default gi&e you the output in the output window and you can stop this ,y the
option N#!"+NT and can take the output in the separate file ,y the statement #UT!UT#UT8 , (ut,
proc summary doesnDt gi&e the default output, we ha&e to e.plicitly gi&e the output statement and then
print the data ,y gi&ing !"+NT option to see the result.
952. Whi"h data set is the "ontro33in- data set in the $!) statement?
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
)&
SAS Faqs
www.arundathiinfotech.com
A6 Dataset ha&ing the less num,er of o,ser&ations control the data set in the merge statement.
95?. What s1stem options wou3d 1ou use to he3p de0u- a ma"ro?
A6 De,ugging a )acro with A ystem #ptions
The A ystem offers users a num,er of useful system options to help de,ug macro issues and
pro,lems. The results associated with using macro options are automatically displayed on the A
Log. pecific options related to macro de,ugging appear in alpha,etical order in the ta,le ,elow.
A #ption Description
$AC!, pecifies that the macro language *)9%T and *)!UT functions ,e a &aila,le.
$$!! $ontrols Diagnostics.
$$!+T pecifies that memory usage statistics ,e displayed on the A Log.
$!!,! !resents 4arning )essages when there are misspellings or when an undefined macro is
called.
$L,)'C )acro e.ecution is traced and displayed on the A Log for de,ugging purposes.
$+!'NT A statements generated ,y macro e.ecution are traced on the A Log for de,ugging
purposes.
S%$E,L)N Displays text from expanding macro variables to te !A! "og#
199 Describe how you would create a macro variable.
Five Ways to Create acro !ariables
$"%& statement
'acro parameters (named and positional)
*terative $+, statement
Using the +NT# in !"#$ FL
Using the $ALL *)!UT routine
2::. Cow do 1ou identif1 a ma"ro varia03e?
A6 )acro &aria,le is a string of te.t and macro &aria,le reference start with ampersand 5Y6.
2:9. Cow do 1ou define the end of a ma"ro?
The end of the macro is defined ,y V)end tatement
2:2. Cow do 1ou assi-n a ma"ro varia03e to a SAS varia03e?
$ALL *)!UT , V Let and !roc Fl.
2:#. For what purposes have 1ou used SAS ma"ros?
A6
+6+f we want use a program step for e.ecuting to e.ecute the same !roc step on multiple data sets.
++64e can accomplish repetiti&e tasks Buickly and efficiently. A macro program can ,e reused many
times. !arameters passed to the macro program customiGe the results without ha&ing to change the
code within the macro program.
+++6)acros in A make a small change in the program and ha&e A echo that change thought that
program.
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
)5
SAS Faqs
www.arundathiinfotech.com
2:&. What is the differen"e 0etween AL,CAL and A)L,EAL?
A6 V Local is a macro &aria,le defined inside a macro.
V9lo,al is a macro &aria,le defined in open code 5outside the macro or can use anywhere6.
2:. . Cow 3on- "an a ma"ro varia03e 0e? A to<en?
A6 A component of A known as the word scanner ,reaks the program te.t into fundamental units
called tokens.
< Tokens are passed on demand to the compiler.
< The compiler then reBuests token until it recei&es a semicolon.
< Then the compiler performs the synta. check on the statement.
2:/. 'f 1ou use a S%$+UT in a DATA step@ when and where "an 1ou use the ma"ro varia03e?
)acro &aria,le is used inside the $all ymput statement and is enclosed in Buotes.
2:2. What do 1ou "ode to "reate a ma"ro? nd one?
V)A$"#
and V)%ND
2:?. What is the differen"e 0etween A+UT and S%$E,L)N?
V!UT is used to display user defined messages on log window after e.ecution of a program where as
V .*)(#L9%N is used to print the &alue of a macro &aria,le resol&ed, on log window.
2:5 . Cow do 1ou add a num0er to a ma"ro varia03e?
Using Ve&al function
29:. Can 1ou e>e"ute a ma"ro within a ma"ro? Des"ri0e.
uch macros are called nested macros. They can ,e o,tained ,y using symget and call symput
macros. PQJJRendifSJJT
299. 'f 1ou need the va3ue of a varia03e rather than the varia03e itse3f what wou3d 1ou use to
3oad the va3ue to a ma"ro varia03e?
+f we need a &alue of a macro &aria,le then we must define it in such terms so that we can call them
e&erywhere in the program. Define it as 9lo,al. There are different ways of assigning a glo,al
&aria,le. implest method is VL%T.
>B
A, is macro &aria,le. Use following statement to assign the &alue of a rather than the &aria,le itself
e.g.
VLet A8.yG
.8;YA;'
This will assign ;.yG; to ., not the &aria,le .yG to ..
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
)6
SAS Faqs
www.arundathiinfotech.com
292. Can 1ou e>e"ute ma"ro within another ma"ro? 'f so@ how wou3d SAS <now where the
"urrent ma"ro ended and the new one 0e-an?
*es, + can e.ecute macro within a macro, what we call it as nesting of macros, which is allowed.
%&ery macroDs ,eginning is identified the keyword Vmacro and end with Vmend.
29#. Cow are parameters passed to a ma"ro?
A macro &aria,le defined in parentheses in a V)A$"# statement is a ma"ro parameter. )acro
parameters allow you to pass information into a macro. -ere is a simple e.ample:
Vmacro plot5y&ar8 ,.&ar8 6'
proc plot'
plot Yy&ar[Y.&ar'
run'
Vmend plot'
29&. Cow wou3d 1ou "ode a ma"ro statement to produ"e information on the SAS 3o-? This
statement "an 0e "oded an1where?
#!T+#N, )!"+NT )L#9+$ )%""#" *)(#L9%N'
Cow we "an "a33 ma"ros with in data step?
A6 4e can call the macro with $ALL*)!UT, !roc FL and VL%T statement.
29. Des"ri0e the t1pes of SAS pro-rammin- tas<s that 1ou performedB Ta03es? Listin-s?
)raphi"s? Ad ho" reports? ,ther?
!repared programs reBuired for the + and +% analysis reports. De&eloped and &alidated programs
for preparing ad@hoc statistical reports for the preparation of clinical study report. 4rote analysis
programs in line with the specifications defined ,y the study statistician. (ase A 5)%AN, >"%F,
U))A"*, TA(ULAT%, "%!#"T etc6 and A2TAT procedures 5"%9, 9L), AN#=A, and
UN+=A"+AT% etc.6 were used for summariGation, $ross@Ta,ulations and statistical analysis purposes.
$reated tatistical reports using !roc "eport, Data _null_ and A )acro. $reated, deri&ed and
merged and pooled datasets,listings and summary ta,les for !hase@+ and !hase@++ of clinical trials.
29/ Cave 1ou 0een invo3ved in editin- the data or writin- data 4ueries?
+f your inter&iewer asks this Buestion, the u should ask him what he means ,y editing the data\ and
data Bueries\
292 What te"hni4ues andOor +!,Cs do 1ou use for ta03es?
!roc >reB,!roc uni&ariate, !roc Ta,ulate Y !roc "eport.
29? Do 1ou prefer +!,C !+,!T or +!,C TAEULAT? Wh1?
+ prefer to use !roc report until + ha&e to create cross ta,ulation ta,les, ,ecause, +t gi&es me so many
options to modify the look up of my ta,le, 5e.: 4idth option, ,y this we can change the width of each
column in the ta,le6 4here as !roc ta,ulate una,le to produce some of the things in my ta,le. %.:
ta,ulate doesnRt produce n 5V6 in the desira,le format.
295 Are 1ou invo3ved in writin- the inferentia3 ana31sis p3an? Ta03eUs spe"ifi"ations?
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
)'
SAS Faqs
www.arundathiinfotech.com
22: What do 1ou fee3 a0out hard"odin-?
!rogrammers sometime hardcode when they need to produce report in urgent. (ut it is always ,etter
to a&oid hard coding, as it o&errides the data,ase controls in clinical data management. Data often
change in a trial o&er time, and the hardcode that is written today may not ,e &alid in the
future.Unfortunately, a hardcode may ,e forgotten and left in the A program, and that can lead to
an incorrect data,ase change.
229 Cow e>perien"ed are 1ou with "ustomi=ed reportin- and use of DATA _NULL_ features?
+ ha&e &ery good e.perience in creating customiGed reports as well as with Data _NULL_ step. +tRs a
Data step that generates a report without creating the dataset there ,y de&elopment time can ,e sa&ed.
The other ad&antages of Data NULL is when we su,mit, if there is any compilation error is there in
the statement which can ,e detected and written to the log there ,y error can ,e detected ,y checking
the log after su,mitting it. +t is also used to create the macro &aria,les in the data set.
222 Cow do 1ou write a test p3an?
(efore writing ;Test plan; you ha&e to look into on ;>unctional specifications;. >unctional
specifications itself depends on ;"eBuirements;, so one should ha&e clear understanding of
reBuirements and functional specifications to write a test plan.
22# What is the differen"e 0etween verifi"ation and va3idation?
Although the &erification and &alidation are close in meaning, ;&erification; has more of a sense of
testing the truth or accuracy of a statement ,y e.amining e&idence or conducting e.periments, while
;&alidate; has more of a sense of declaring a statement to ,e true and marking it with an indication of
official sanction.
EAS SAS 4uestionsB
22& What is the differen"e 0etween nodup and nodup<e1 options?
N#DU! compares all the &aria,les in our dataset while N#DU!O%* compares Eust the (* &aria,les.
22. What is the differen"e 0etween "ompi3er and interpreter? )ive an1 one e>amp3e 6software
produ"t8 that a"t as an interpreter?
(oth are similar as they achie&e similar purposes, ,ut inherently different as to how they achie&e that
purpose. The interpreter translates instructions one at a time, and then e.ecutes those instructions
immediately. $ompiled code takes programs 5source6 written in A programming language, and
then ultimately translates it into o,Eect code or machine language. $ompiled code does the work much
more efficiently, ,ecause it produces a complete machine language program, which can then ,e
e.ecuted.
22/ Code the ta03eUs statement for a sin-3e 3eve3 fre4uen"1?
!roc freB data8li,.dataset'
ta,le &ar' [here you can mention single &aria,le of multiple
&aria,les seperated ,y space to get single
freBuency'
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
)Q
SAS Faqs
www.arundathiinfotech.com
run'
222 What is the main differen"e 0etween rename and 3a0e3?
?. La,el is glo,al and rename is local i.e., la,el statement can ,e used either in proc or data step where
as rename should ,e used only in data step. M.+f we rename a &aria,le, old name will ,e lost ,ut if we
la,el a &aria,le its short name 5old name6 e.ists along with its descripti&e name.
22? What is pi"ture format? )ive an1 one e>amp3e?
]H@@^if Hsupport%mpty!aras_@@` !icture format writes a template for numeric
!roc format '
!icture sno
Low @ @? 8 DCC.CCD
C@J8DJ.JJJD
?C@JJ8DJJ.JJD
?CC@JJJ8DJJJ.JD
'
4hen you specify Gero as the digit selector, any leading Geros in the num,er to ,e displayed are
shownas ,lanks. 4hen nine is specified as the digit selector, the leading Geros are displayed in the
output.
225 What is nterprise )uide? What is the use of it?
+t is an approach to import te.t files with A 5+t comes free with (ase A &ersion J.C6
2#: What other SAS features do 1ou use for error trappin- and data va3idation? What are the
va3idation too3s in SAS?
>or dataset
Data set name2de,ug
Data set name2stmtchk
>or macros
#ptions:
mprint mlogic sym,olgen.
2#9 Cow "an 1ou put a 9trace9 in :o"r pro;ram?
&4S "race &(# &4S "race &88 the trace records.
232 <o= =o"ld :o" code a mer;e t5at =ill >eep onl: t5e o6ser?ations t5at 5a?e
mat"hes from 0oth data sets?
Using ;+N; &aria,le option. Look at the following e.ample.
data three'
merge one5in8.6 two5in8y6'
,y id'
if .8? and y8?'
run'
or
data three'
merge one5in8.6 two5in8y6'
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
)(
SAS Faqs
www.arundathiinfotech.com
,y id'
if . and y'
run'
2#& What are input dataset and output dataset options?
+nput data set options are o,s, firsto,s, where, in output data set options compress, reuse.(oth input
and output dataset options include keep, drop, rename, o,s, first o,s.
2#. What other SAS features do 1ou use for error trappin- and data va3idation?
$onditional statements, if then else.
!ut statement
De,ug option
2#/ Cow "an u "reate =ero o0servation dataset?
$reating a data set ,y using the like clause.
e.: proc sBl'
create ta,le latha.emp like oracle.emp'
Buit'
+n this the like clause triggers the e.isting ta,le structure to ,e copied to the new ta,le. using this
method result in the creation of an empty ta,le.
2#2 Cave 1ou ever 3in<ed SAS "ode@ 'f so@ des"ri0e the 3in< and an1 re4uired statements used
to either pro"ess the "ode or the step itse3f?
+n the editor window we write
Vinclude Dpath of the sas fileD'
run'
if it is with non@windowing en&ironment no need to gi&e run statement.
2#? Cow "an u import .CS( fi3e in to SAS? te33 S1nta>?
To create $= file, we ha&e to open notepad, then, declare the &aria,les. Then sa&e the file like .$=.
*NTA/: proc import datafile8De.ternal fileD
out8 d,ms8cs& replace'
getnames8yes'
proc print data8
run'
eg:proc import datafile8D%:Wage.cs&D
out8sarath
d,ms8cs& replace'
getnames8yes'
proc print data8sarath'
run'
2#5 What is the use of +ro" SQ3?
!"#$ FL is a powerful tool in A, which com,ines the functionality of data and proc steps.
!"#$ FL can sort, summariGe, su,set, Eoin 5merge6, and concatenate datasets, create new &aria,les,
and print the results or create a new dataset all in one stepH !"#$ FL uses fewer resources when
compared to that of data and proc steps. To Eoin files in !"#$ FL it does not reBuire to sort the data
prior to merging, which is must, is data merge.
2&: What is SAS )!A+C?
A29"A!- software creates and deli&ers accurate, high@impact &isuals that ena,le decision makers
to gain a Buick understanding of critical ,usiness issues.
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
&0
SAS Faqs
www.arundathiinfotech.com
2&9 Cow wou3d 1ou -enerate 9::: o0servations from a norma3 distri0ution with a mean of .:
and
standard deviation of 2:? Cow wou3d 1ou use +!,C CCA!T to 3oo< at the distri0ution?
Des"ri0e the
shape of the distri0ution.
data temp5keep8.6'
retain mu LC std MC seed C'
do i8? to ?CCC'
.8mu1std[rannor5seed6'
output'
end'
run'
proc chart data8temp'
&,ar .'
run'
normal distri,ution with mean 8LC and std8MC
2&2 Wh1 is a ST,+ statement needed for the point;option on a ST statement?
4hen you use the !#+NT8 option, you must include a T#! statement to stop DATA step processing,
programming logic that checks for an in&alid &alue of the !#+NT8 &aria,le, or (oth. (ecause
!#+NT8 reads only those o,ser&ations that are specified in the D# statement, A
cannot read an end@of@file indicator as it would if the file were ,eing read seBuentially. (ecause
reading an end@of@file indicator ends a DATA step automatically, failure to su,stitute another means of
ending the DATA step when you use !#+NT8 can cause the DATA step to go into a continuous loop.
2&# What is +!,C CD'SC?
+t is new A procedure that is a&aila,le as a hotfi. for A 3.M &ersion and comes as a part with
A J.?.N &ersion. !"#$ $D+$ is a procedure that allows us to import 5and e.port /)L files that
are compliant with the $D+$ #D) &ersion ?.M schema.
2&& Cave 1ou used ma"ros? For what purpose 1ou have used?
*es + ha&e, + used macros in creating analysis datasets and ta,les 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.
2&. Cow wou3d 1ou invo<e a ma"ro?
After + ha&e defined a macro + can in&oke it ,y adding the percent sign prefi. to its name like this: V
macro name a semicolon is not reBuired when in&oking a macro, though adding one generally does no
harm.
2&/ Cow "an 1ou "reate a ma"ro varia03e with in data step?
with $ALL *)!UT
2&2 Cow wou3d 1ou identif1 a ma"ro varia03e?
with Ampersand 5Y6 sign
2&? Cow wou3d 1ou define the end of a ma"ro?
The end of the macro is defined ,y V)end tatement
2&5 For what purposes have 1ou used SAS ma"ros?
+f we want use a program step for e.ecuting to e.ecute the same !roc step on multiple data sets. 4e
can accomplish repetiti&e tasks Buickly and efficiently. A macro program can ,e reused many times.
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
&+
SAS Faqs
www.arundathiinfotech.com
!arameters passed to the macro program customiGe the results without ha&ing to change the code
within the macro program. )acros in A make a small change inthe program and ha&e A echo
that change thought that program.
2.: What is the differen"e 0etween AL,CAL and A)L,EAL?
V Local is a macro &aria,le defined inside a macro.V9lo,al is a macro &aria,le defined in open code
5outside the macro or can use anywhere6.
2.9 Cow 3on- "an a ma"ro varia03e 0e? A to<en?
A component of A known as the word scanner ,reaks the program te.t into fundamental units
called tokens.
< Tokens are passed on demand to the compiler.
< The compiler then reBuests token until it recei&es a semicolon.
< Then the compiler performs the synta. check on the statement.
2.2 'f 1ou use a S%$+UT in a DATA step@ when and where "an 1ou use the ma"ro varia03e?
The macro &aria,le created ,y the $ALL *)!UT routine cannot ,e used in the same datastep in
which it got created. #ther than that we can use the macro &aria,le at any time..
2.# What do 1ou "ode to "reate a ma"ro? nd one?
4e create a macro with A)A$"# statement and end a macro with V)%ND statemnt.
2.& What is the differen"e 0etween A+UT and S%$E,L)N?
V!UT is used to display user defined messages on log window after e.ecution of a program where as
V *)(#L9%N is used to print the &alue of a macro &aria,le resol&ed, in log window.
2.. Cow do 1ou add a num0er to a ma"ro varia03e?
Using Ve&al function or Vsyse&alf function if the num,er is a floating num,er.
2./ Can 1ou e>e"ute a ma"ro within a ma"ro? Des"ri0e.
*es, uch macros are called nested macros. They can ,e o,tained ,y using symget and call symput
macros.
2.2 'f 1ou need the va3ue of a varia03e rather than the varia03e itse3f what wou3d 1ou use to
3oad the va3ue to a ma"ro varia03e?
+f we need a &alue of a macro &aria,le then we must define it in such terms so that we can call them
e&erywhere in the program. Define it as 9lo,al. There are different ways of assigning a glo,al
&aria,le. implest method is VL%T.
>B
A, is macro &aria,le. Use following statement to assign the &alue of a rather than the &aria,le itself
ALet A8.yG' Aput .8;YA;'
This will assign ;.yG; to ., not the &aria,le .yG to ..
2.? Can 1ou e>e"ute ma"ro within another ma"ro? 'f so@ how wou3d SAS <now where the
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
&*
SAS Faqs
www.arundathiinfotech.com
"urrent ma"ro ended and the new one 0e-an?
*es, + can e.ecute macro within a macro, we call it as nesting of macros, which is allowed.
%&ery macroDs ,eginning is identified the keyword Vmacro and end with Vmend.
2.5 Cow are parameters passed to a ma"ro?
A macro &aria,le defined in parentheses in a V)A$"# statement is a macro parameter. )acro
parameters allow you to pass information into a macro.
Cere is a simp3e e>amp3eB
Ama"ro p3ot5y&ar8 ,.&ar8 6'
pro" plot'
plot Yy&ar[Y.&ar'
run'
Amend p3ot'
Ap3ot5age,se.6
2/: Cow wou3d 1ou "ode a ma"ro statement to produ"e information on the SAS 3o-?
This statement can ,e coded anywhere7
,+T',NS )!"+NT )L#9+$ )%""#" *)(#L9%N'
2/9 Cow we "an "a33 ma"ros with in data step?
4e can call the macro with
$ALL *)!UT,
!roc FL ,
VL%T statement. and macro parameters.
2/2 Te33 me a0out "a33 s1mput?
$ALL *)!UT takes a &alue from a data step and assigns it to a macro &aria,le. + can then use this
macro &aria,le in later steps. To assign a &alue to a single macro &aria,le,
+ use $ALL *)!UT with this general form:
$ALL S%$+UT 5Smacro@&aria,le@nameT, &alue6'
4here macro@&aria,le@name, enclosed in Buotation marks, is the name of a macro &aria,le, and &alue
is the &alue + want to assign to that macro &aria,le. =alue can ,e the name of a &aria,le whose &alue
A will use, or it can ,e a constant &alue enclosed Buotation marks.
$ALL S%$+UT is often used in if@then statements such as this:
+f age`8?3 then "a33 s1mput 5SstatusT,TadultT6'
else "a33 s1mput 5SstatusT,TminorT6'
These statements create a macro &aria,le named Ystatus and assign to it a &alue of either adult or
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
&)
SAS Faqs
www.arundathiinfotech.com
minor depending on the &aria,le age.$aution: 4e cannot create a macro &aria,le with $ALL
*)!UT and use it in the same data step ,ecause A does not assign a &alue to the macro &aria,le
until the data step e.ecutes. Data steps e.ecutes when A encounters a step ,oundary such as a
su,seBuent data, proc, or run statement.
2/#. Te33 me a0out A in"3ude and A eva3?
The Vinclude statement, despite its percent sign, is not a macro statement and is always e.ecuted in
A, though it can ,e conditionally e.ecuted in a macro.+t can ,e used to setting up a macro li,rary.
(ut this is a least approach.
The use of Vinclude does not actually set up a li,rary. The Vinclude statement points to a file and
when it e.ecuted the indicated file 5,e it a full program, macro definition, or a statement 5fragment6 is
inserted into the calling program at the location of the call.
4hen using the Vinclude ,uilding a macro li,rary, the included file will usually contain one or more
macro definitions.V%=AL is a widely used yet freBuently misunderstood A5r6 macro language
function due to its seemingly simple form.
-owe&er, when its actual argument is a comple. macro e.pression interlaced with special characters,
mi.ed arithmetic and logical operators, or macro Buotation functions, its usage and result ,ecome
elusi&e and pro,lematic. V+> condition in macro is e&aluated ,y Ve&al, to reduce it to true or false.
2/& Des"ri0e the wa1s in whi"h 1ou "an "reate ma"ro varia03es?
There are the L ways to create macro &aria,les:
VLet @V9lo,al
$all ymput
!roc Fl into clause
)acro !arameters.
2/. Te33 me more a0out the parameters in ma"ro?
!arameters are macro &aria,les whose &alue you set when you in&oke a macro. To add the parameters
to a macro, you simply name the macro &ars names in parenthesis in the Vmacro statement.
S1nta>B
A$AC!, ma"roJname (para(eter/1= , para(eter/,= , 00para(eter/n
= !;
(a%r&/te1t2;
%!"# macro-name;
%macro$name(par1,par,,3333parn!;
2// What is the ma>imum 3en-th of the ma"ro varia03e?
NM characters long.
2/2 Automati" varia03es for ma"ro?
%&ery time we in&oke A, the macro processor automatically creates certain macro &ar. eg:
Ysysdate Ysysday.
2/? What s1stem options wou3d 1ou use to he3p de0u- a ma"ro?
The A ystem offers users a num,er of useful system options to help de,ug macro issues and
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
&&
SAS Faqs
www.arundathiinfotech.com
pro,lems. The results associated with using macro options are automatically displayed on the A
Log.
pecific options related to macro de,ugging appear in alpha,etical order in the ta,le ,elow:
$$!+TB pecifies that memory usage statistics ,e displayed on the A Log.
$!!,!B A will issue warning if we in&oke a macro that A didnRt find. !resents 4arning
)essages when there are misspellings or when an undefined macro is called.
S!!,!B A will issue warning if we use a macro &aria,le that A canRt find.
$L,)'CB A prints details a,out the e.ecution of the macros in the log.
$+!'NTB Displays A statements generated ,y macro e.ecution are traced on the A Log for
de,ugging purposes.
S%$E,L)NB A prints the &alue of macro &aria,les in log and also displays te.t from
e.panding macro &aria,les to the A Log.
2/5 What are the ma"ros 1ou have used in 1our pro-rams?
Used macros for &arious puposes, few of them are..
22: What is auto "a33 ma"ro and how to "reate a auto "a33 ma"ro? What is the use of it? Cow to
use it in SAS with ma"ros?
The auto call macro facility allows users to access the same macro code from multiple A programs.
"ather than ha&ing the same macro code for in each program where the code is reBuired, with an
autocall macro, the code is in one location. This permits faster updates and ,etter consistency across
all the programs.)acro set@up:The fist step is to set@up a program that contains a macro, desired to ,e
used in multiple programs. Although the program may contain other macros and2or open code, it is
ad&ised to include only one macro.
229 Wh1 and Cow to Use A+UT StatementB
V!ut statement is similar to the !UT statement in data step, 4hat it does is it writes te.t and &alues of
macro &aria,le after e.ecution to the A ystem L#9. +f you want to make sure your macro
&aria,le resol&es as e.pected, you can make sure it with V!UT statement.
UniBue ad&antage of V!UT o&er !UT is \you can use V!UT outside the data step whereas you
canRt with !UT.
222 Cow to use A+UTB
Vlet program8A%'
Vput program Name here as Yprogram'
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
&5
SAS Faqs
www.arundathiinfotech.com
A,o&e Vput statement resol&es to \ Vput !rogram Name here as A%'
22# What "an 1ou do with A+UTB
Numerous options are a&aila,le for the V!UT statement.
22& A+UT _a33_B
+t prints all macro &aria,les in the log that are a&aila,le in all en&ironments 5glo,al, local, user and
automatic6.
22. A+UT _automati"_B
+t prints all the A defined automatic macro &aria,les in the log. 5e.: Ysysdate, Ysystime ,Vsysdsn,
Vsyserr etc6
22/ A+UT _-3o0a3_B
+t prints macro &aria,les that are created ,y the user and a&aila,le in all en&ironments.
222 A+UT _3o"a3_B
+t prints macro &aria,les that are created ,y the user and a&aila,le only in the local en&ironment.
5couldnRt ,e a,le use those macro &aria,les outside the particular data step6
22? A+UT _user_B
+t prints macro &aria,les that are created ,y the user in each en&ironment.
225 What SAS statements wou3d 1ou "ode to read an e>terna3 raw data fi3e to a DATA step?
+N>+L% statement.
2?: Cow do 1ou read in the varia03es that 1ou need?
Using +nput statement with the column pointers like 0L2?M@?U etc.
2?9 Are 1ou fami3iar with spe"ia3 input de3imiters? Cow are the1 used?
DL) and DD are the delimiters that +R&e used. They should ,e included in the infile statement.
$omma separated &alues files or $= files are a common type of file that can ,e used to read with the
DD option. DD option treats two delimiters in a row as )++N9 &alue. DD also ignores the
delimiters enclosed in Buotation marks.
2?2 'f readin- a varia03e 3en-th fi3e with fi>ed input@ how wou3d 1ou prevent SAS from readin-
the ne>t re"ord if the 3ast varia03e didnDt have a va3ue?
(y using the option )+#=%" in the infile statement. +f the input of some data lines are shorter
than others then we use T"UN$#=%" option in the infile statement.
2?# What is the differen"e 0etween an informat and a format? Name three informats or
formats.
+nformats read the data. >ormat is to write the data.
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
&6
SAS Faqs
www.arundathiinfotech.com
+nformats: comma. dollar. date.>ormats can ,e same as informats
+nformats: ))DD**w. DAT%w. T+)%w. , !%"$%NTw,
>ormats: 4#"D+AT%?3., weekdatew.
2?& Name and des"ri0e three SAS fun"tions that 1ou have used@ if an1?
L%N9T-: returns the length of an argument not counting the trailing ,lanks.5missing &alues ha&e a
length of ?6
%.: a8Rmy catR'
.8L%N9T-5a6' "esult: .8K\
U(T": U(T"5arg,position,n6 e.tracts a su,string from an argument starting at apositionR for anR
characters or until end if no anR.
%.: A8R5J?K6UNX@KMX?R'
/8U(T"5a,M,N6' "%ULT: .8RJ?KR
T"+): remo&es trailing ,lanks from character e.pression.
%.: a8Rmy a' ,8RcatR'
/8 T"+)5a65,6' "%ULT: .8RmycatR.
U): sum of non missing values.
Ex: x=Sum(3,5,1); result: x=9.0
+NT: "eturns the integer portion of the argument.
< -ow would you code the criteria to restrict the output to ,e produced7
Use N#!"+NT option.
2?. What is the purpose of the trai3in- 7 and the 77? Cow wou3d 1ou use them?
0 holds the &alue past the data step.
00 holds the &alue till a input statement or end of the line.
Dou,le trailing 00: 4hen you ha&e multiple o,ser&ations per line of raw data, we should use dou,le
trailing signs 5006 at the end of the +N!UT statement. The line hold specifies like a stop sign telling
A, Sstop, hold that line of raw dataT.
Trailing 0: (y using 0 without specifying a column, it is as if you are telling A,T stay tuned for
more information. DonRt touch that dialT. A will hold the line of data until it reaches either the end
of the data step or an +N!UT statement that does not end with the trailing.
2?/ Under what "ir"umstan"es wou3d 1ou "ode a SLCT "onstru"t instead of 'F statements?
4hen you ha&e a long series of mutually e.clusi&e conditions and the comparison is numeric, using a
%L%$T group is slightly more efficient than using +>@T-%N or +>@T-%N@%L% statements ,ecause
$!U time is reduced.
%L%$T 9"#U!:
elect: ,egins with select group.
4hen: identifies A statements that are e.ecuted when a particular condition is true.
#therwise 5optional6: specifies a statement to ,e e.ecuted if no 4-%N condition is met.
%nd: ends a %L%$T group.
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
&'
SAS Faqs
www.arundathiinfotech.com
2?2 What statement 1ou "ode to te33 SAS that it is to write to an e>terna3 fi3e? What statement
do 1ou "ode to write the re"ord to the fi3e?
!UT and >+L% statements.
2?? 'f readin- an e>terna3 fi3e to produ"e an e>terna3 fi3e@ what is the short"ut to write that
re"ord without "odin- ever1 sin-3e varia03e on the re"ord?
V 'f 1ouDre not wantin- an1 SAS output from a data step@ how wou3d 1ou "ode the data statement
to prevent SAS from produ"in- a set?
Data _Null_
2?5 What is the one statement to set the "riteria of data that "an 0e "oded in an1 step?
#ptions statement: This a part of A program and effects all steps that follow it.
25: Cave 1ou ever 3in<ed SAS "ode? 'f so@ des"ri0e the 3in< and an1 re4uired statements used
to either pro"ess the "ode or the step itse3f.
V Cow wou3d 1ou in"3ude "ommon or reuse "ode to 0e pro"essed a3on- with 1our statements?
(y using A )acros.
259 When 3oo<in- for data "ontained in a "hara"ter strin- of 9.: 01tes@ whi"h fun"tion is the
0est to 3o"ate that dataB s"an@ inde>@ or inde>"?
$AN.
252 'f 1ou have a data set that "ontains 9:: varia03es@ 0ut 1ou need on31 five of those@ what is
the "ode to for"e SAS to use on31 those varia03e?
Using O%%! option or statement.
25# Code a +!,C S,!T on a data set "ontainin- State@ Distri"t and Count1 as the primar1
varia03es@ a3on- with severa3 numeri" varia03es.
!roc sort data8
(* tate District $ounty '
"un '
25& Cow wou3d 1ou de3ete dup3i"ate o0servations?
N#NU!L+$AT%
25. Cow wou3d 1ou de3ete o0servations with dup3i"ate <e1s?
N#DU!O%*
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
&Q
SAS Faqs
www.arundathiinfotech.com
25/ Cow wou3d 1ou "ode a mer-e that wi33 <eep on31 the o0servations that have mat"hes from
0oth sets.
$heck the condition ,y using +f statement in the )erge statement while merging datasets.
252 Cow wou3d 1ou "ode a mer-e that wi33 write the mat"hes of 0oth to one data set@ the nonJ
mat"hes from the 3eftJmost data.
tep?: Define N datasets in DATA step
tepM: Assign &alues of +N statement to different &aria,les for M datasets
tepN: $heck for the condition using +> statement and output the matching to first dataset and no
matches to different datasets
%.: data ...merge yyy5in 8 in...6 GGG 5in 8 inGGG6',y aaa'if in... 8 ? and inyyy 8 ?'run'
25? What is the +ro-ram Data (e"tor 6+D(8? What are its fun"tions?
>unction: To store the current o,s'
!D= 5!rogram Data =ector6 is a logical area in memory where A creates a dataset one o,ser&ation
at a time. 4hen A processes a data step it has two phases. $ompilation phase and e.ecution phase.
During the compilation phase the input ,uffer is created to hold a record from e.ternal file. After
input ,uffer is created the !D= is created. The !D= is the area of memory where A ,uilds dataset,
one o,ser&ation at a time. The !D= contains two automatic &aria,les _N_ and _%""#"_.
MJJ Does SAS DTrans3ateD 6"ompi3e8 or does it D'nterpretD? >p3ain.
A compiles the code
< At compile time when a A data set is read, what items are created7
Automatic &aria,les are created. +nput (uffer, !D= and Descriptor +nformation
#:: Name statements that are re"o-ni=ed at "ompi3e time on31?
!UT
#:9 Name statements that are e>e"ution on31.
INFILE, INPU
#:2 'dentif1 statements whose p3a"ement in the DATA step is "riti"a3.
DATA, +N!UT, "UN.
#:# Name statements that fun"tion at 0oth "ompi3e and e>e"ution time.
+N!UT
#:& 'n the f3ow of DATA step pro"essin-@ what is the first a"tion in a t1pi"a3 DATA Step?
The DATA step ,egins with a DATA statement. %ach time the DATA statement e.ecutes, a new
iteration of the DATA step ,egins, and the _N_ automatic &aria,le is incremented ,y ?.
#:. WhatDs the differen"e 0etween (A! A9 J A& and (A! A9 JJ A& ?
A: There is no diff ,etween =A" A?@AX an =A" A?QAX. 4here as +f u su,mit =A" A?@@@AX instead
of =A" A?@AX or =A" A?QAN, u will see error message in the log.
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
&(
SAS Faqs
www.arundathiinfotech.com
#:/ What do the SAS 3o- messa-es Lnumeri" va3ues have 0een "onverted to "hara"terL mean?
What are the imp3i"ations?
+t implies that automatic con&ersion took place to make character functions possi,le
#:2 Wh1 is a ST,+ statement needed for the +,'NT; option on a ST statement?
(ecause !#+NT8 reads only the specified o,ser&ations, A cannot detect an end@of@file condition as
it would if the file were ,eing read seBuentially.
#:? Cow do 1ou "ontro3 the num0er of o0servations andOor varia03es read or written?
>+"T#( and #( option
#:5 Appro>imate31 what date is represented 01 the SAS date va3ue of 2#:?
N?st Decem,er ?JK?
#9: 'dentif1 statements whose p3a"ement in the DATA step is "riti"a3.
A: +N!UT, DATA and "UN\
#99 Does SAS DTrans3ateD 6"ompi3e8 or does it D'nterpretD? >p3ain.
A6 $ompile
#92 Wh1 is SAS "onsidered se3fJdo"umentin-?
A6 A is considered self documenting ,ecause during the compilation time it creates and stores all
the information a,out the data set like the time and date of the data set creation later No. of the
&aria,les later la,els all that kind of info inside the dataset and you can look at that info
using proc contents procedure.
#9# What are some -ood SAS pro-rammin- pra"ti"es for pro"essin- ver1 3ar-e data sets?
A6 ort them once, can use firsto,s 8 and o,s 8 ,
#9& 'f 1ou were to3d to "reate man1 re"ords from one re"ord@ show how 1ou
wou3d do this usin- arra1s and with +!,C T!ANS+,S?
A6 + would use T"AN!#% if the &aria,les are less use arrays if the &ar are more ................depends
#9. What is a method for assi-nin- first.(A! and 3ast.(A! to the E% -roup varia03e on
unsorted data?
A6 +n Unsorted data you canDt use >irst. or Last.
#9/ Cow do 1ou de0u- and test 1our SAS pro-rams?
A6 >irst thing is look into Log for errors or warning or N#T% in some cases or use the de,ugger in
A data step.
#92 What other SAS features do 1ou use for error trappin- and data
va3idation?
A6 $heck the Log and for data &alidation things like !roc >reB, !roc means or some times proc print
to look how the data looks like ........
#9? Cow wou3d 1ou "om0ine # or more ta03es with different stru"tures?
A6 + think sort them with common &aria,les and use merge statement. + am not sure what you mean
different structures.
#95 What areas of SAS are 1ou most interested in?
(A%, TAT, 9"A!-, %T
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
50
SAS Faqs
www.arundathiinfotech.com
#2: Erief31 des"ri0e . wa1s to do a Lta03e 3oo<upL in SAS.
)atch )erging, Direct Access, >ormat Ta,les, Arrays, !"#$ FL
#29 What versions of SAS have 1ou used 6on whi"h p3atforms8?
A 3.M in 4indows and UN+/, A U and K.?M
#22 What are some -ood SAS pro-rammin- pra"ti"es for pro"essin- ver1 3ar-e data sets?
ampling method using #( option or su,setting, commenting the Lines, Use Data Null
#2# What are some pro03ems 1ou mi-ht en"ounter in pro"essin- missin- va3ues? 'n Data steps?
Arithmeti"? Comparisons? Fun"tions? C3assif1in- data?
The result of any operation with missing &alue will result in missing &alue. )ost A statistical
procedures e.clude o,ser&ations with any missing &aria,le &alues from an analysis.
#2& Cow wou3d 1ou "reate a data set with 9 o0servation and #: varia03es from a data set with
#: o0servations and 9 varia03e?
Using !"#$ T"AN!#%
#2. What is the different 0etween fun"tions and +!,Cs that "a3"u3ate the same simp3e
des"riptive statisti"s?
!roc can ,e used with wider scope and the results can ,e sent to a different dataset. >unctions usually
affect the e.isting datasets.
#2/ 'f 1ou were to3d to "reate man1 re"ords from one re"ord@ show how 1ou wou3d do this usin-
arra1 and with +!,C T!ANS+,S?
Declare array for num,er of &aria,les in the record and then used Do loop
!roc Transpose with =A" statement
#22 What are _numeri"_ and _"hara"ter_ and what do the1 do?
4ill either read or writes all numeric and character &aria,les in dataset.
#22 Cow wou3d 1ou "reate mu3tip3e o0servations from a sin-3e o0servation?
Using dou,le Trailing 00
#2? For what purpose wou3d 1ou use the !TA'N statement?
The retain statement is used to hold the &alues of &aria,les across iterations of the data step. Normally,
all &aria,les in the data step are set to missing at the start of each iteration of the data step.
#25 What is the order of eva3uation of the "omparison operatorsB G J K O KK 68?
56, [[, [, 2, 1, @
##: Cow "ou3d 1ou -enerate test data with no input data?
Using Data Null and put statement
##9 Cow do 1ou de0u- and test 1our SAS pro-rams?
Using #,s8C and systems options to trace the program e.ecution in log.
##2 What "an 1ou 3earn from the SAS 3o- when de0u--in-?
+t will display the e.ecution of whole program and the logic. +t will also display the error with line
num,er so that you can and edit the program.
### What is the purpose of _error_?
+t has only to &alues, which are ? for error and C for no error
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
5+
SAS Faqs
www.arundathiinfotech.com
##& Cow "an 1ou put a Ltra"eL in 1our pro-ram?
(y using #D T"A$% #N
##. Cow does SAS hand3e missin- va3ues inB assi-nment statements@ fun"tions@ a mer-e@ an
update@ sort order@ formats@ +!,Cs?
)issing &alues will ,e assigned as missing in Assignment statement. ort order treats missing as
second smallest followed ,y underscore.
##/ Cow do 1ou test for missin- va3ues?
Using u,set functions like +> then %lse, 4here and elect
##2 Cow are numeri" and "hara"ter missin- va3ues represented interna331?
$haracter as (lank or S and Numeric as.
NN3 Whi"h date fun"tions advan"es a date time or dateOtime va3ue 01 a -iven interva3?
+NTN/.
##5 'n the f3ow of DATA step pro"essin-@ what is the first a"tion in a t1pi"a3 DATA Step?
4hen you su,mit a DATA step, A processes the DATA step and then creates a new A data set.
5 creation of input ,uffer and !D=6
$ompilation !hase
%.ecution !hase
#&o What are SASOACCSS and SASOC,NNCT?
A2Access only process through the data,ases like #racle, FL@ser&er, )s@Access etc.
A2$onnect only use er&er connection.
#&9 What is the one statement to set the "riteria of data that "an 0e "oded in an1 step?
#!T+#N tatement, La,el statement, Oeep 2 Drop statements.
#&2 What is the purpose of usin- the N;+S option?
The N8! option creates a ,uffer in memory which is large enough to store !A9%+:% 5!6 lines and
ena,les a page to ,e formatted randomly prior to it ,eing printed.
#&# What are the s"ru00in- pro"edures in SAS?
!roc ort with nodupkey option, ,ecause it will eliminate the duplicate &alues.
#&& What has 0een 1our most "ommon pro-rammin- mista<e?
)issing semicolon and not checking log after su,mitting program, Not using de,ugging techniBues
and not using >s&iew option &igorously.
#&. Name severa3 wa1s to a"hieve effi"ien"1 in 1our pro-ram. >p3ain tradeJoffs. %fficiency and
performance strategies can ,e classified into L different areas. <
C+U time
VData Stora-e
V 3apsed time
V 'nputO,utput
V $emor1
$!U Time and %lapsed Time@ (ase line measurements >ew %.amples for efficiency &iolations:
"etaining unwanted datasets Not su, setting early to eliminate unwanted records.
ffi"ien"1 improvin- te"hni4uesB Using O%%! and D"#! statements to retain necessary &aria,les.
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
5*
SAS Faqs
www.arundathiinfotech.com
Use macros for reducing the code. Using +>@T-%N2%L% statements to process data programming.
Use FL procedure to reduce num,er of programming steps. Using of length statements to reduce the
&aria,le siGe for reducing the Data storage.
Use of Data _NULL_ steps for processing null data sets for Data storage.
#&/ What other SAS produ"ts have 1ou used and "onsider 1ourse3f profi"ient in usin-? Data
_NULL_ statement, !roc )eans, !roc "eport, !roc ta,ulate, !roc freB and !roc print, !roc Uni&ariate
etc.
#&2 What is the si-nifi"an"e of the D,FD in *;SU$ 6,F a9Ja&@ a/@ a58I
+f donRt use the #> function it might not ,e interpreted as we e.pect. >or e.ample the function a,o&e
calculates the sum of a? minus aX plus aK and aJ and not the whole sum of a? to aX Y aK and aJ. +t is
true for mean option also.
#&? What do the +UT and 'N+UT fun"tions do?
+N!UT function con&erts character data &alues to numeric &alues. !UT function con&erts numeric
&alues to character &alues.
%/: for +N!UT: +N!UT 5source, informat6
>or !UT: !UT 5source, format6
Note that +N!UT function reBuires +N>#")AT and !UT function reBuires >#")AT. +f we omit the
+N!UT or the !UT function during the data con&ersion, A will detect the mismatched &aria,les and
will try an automatic character@to@numeric or numeric@to@character con&ersion. (ut sometimes this
doesnRt work ,ecause Z sign pre&ents such con&ersion. Therefore it is always ad&isa,le to include
+N!UT and !UT functions in your programs when con&ersions occur.
#&5 Whi"h date fun"tion advan"es a date@ time or datetime va3ue 01 a -iven interva3?
'NTN*B +NTN/ function ad&ances a date, time, or datetime &alue ,y a gi&en inter&al, and returns a
date, time, or datetime &alue. %.: +NTN/5inter&al,start@from,num,er@of@increments,alignment6
'NTCNB +NT$O5inter&al,start@of@period,end@of@period6 is an inter&al functioncounts the num,er of
inter&als ,etween two gi&e A dates, Time and2or datetime. DAT%T+)% 56 returns the current date
and time of day. DATD+> 5sdate,edate,,asis6: returns the num,er of days ,etween two dates.
#.: 'n A!!A% pro"essin-@ what does the D'$ fun"tion do?
D+): +t is used to return the num,er of elements in the array. 4hen we use Dim function we would
ha&e to re Aspecify the stop &alue of an iterati&e D# statement if u change the dimension of the array.
#.9 Cow wou3d 1ou determine the num0er of missin- or nonmissin- va3ues in "omputations?
To determine the num,er of missing &alues that are e.cluded in a computation, use the N)+
function.
data _null_'
m 8 . ' y 8 X ' G 8 C '
N 8 N5m , y, G6'
N)+ 8 N)+ 5m , y, G6'
run'
The a,o&e program results in N 8 M 5Num,er of non missing &alues6 and N)+ 8 ? 5num,er of
missing &alues6.
#.2 What is the differen"e 0etween "a3"u3atin- the DmeanD usin- the mean fun"tion and +!,C
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
5)
SAS Faqs
www.arundathiinfotech.com
)%AN7
(y default !roc )eans calculate the summary statistics like N, )ean, td de&iation, )inimum and
ma.imum, 4here as )ean function compute only the mean &alues.
What are some differen"es 0etween +!,C SU$$A!% and +!,C $ANS?
!roc means ,y default gi&e you the output in the output window and you can stop this ,y the option
N#!"+NT and can take the output in the separate file ,y the statement #UT!UT#UT8 , (ut, proc
summary doesnDt gi&e the default output, we ha&e to e.plicitly gi&e the output statement and then
print the data ,y gi&ing !"+NT option to see the result.
#.# Whi"h data set is the "ontro33in- data set in the $!) statement?
Dataset ha&ing the less num,er of o,ser&ations control the data set in the merge statement.
#.& Cow do the 'N; varia03es improve the "apa0i3it1 of a $!)?
The +N8&aria,les
4hat if you want to keep in the output data set of a merge only the matches 5only those o,ser&ations
to which ,oth input data sets contri,ute67 A will set up for you special temporary &aria,les, called
the ;+N8; &aria,les, so that you can do this and more. -ereDs what you ha&e to do: signal to A on
the )%"9% statement that you need the +N8 &aria,les for the input data set5s6 use the +N8 &aria,les
in the data step appropriately, o to keep only the matches in the match@merge a,o&e, ask for the +N8
&aria,les and use them:
data three'
merge one5in8.6 two5in8y6' 2[ . Y y are your choices of names [2
,y id' 2[ for the +N8 &aria,les for data [2
if .8? and y8?' 2[ sets one and two respecti&ely [2
run'
#.. What is the differen"e 0etween "ompi3er and interpreter? )ive an1 one e>amp3e 6software
produ"t8 that a"t as an interpreter?
(oth are similar as they achie&e similar purposes, ,ut inherently different as to how they achie&e that
purpose. The interpreter translates instructions one at a time, and then e.ecutes those instructions
immediately. $ompiled code takes programs 5source6 written in A programming language, and
then ultimately translates it into o,Eect code or machine language. $ompiled code does the work much
more efficiently, ,ecause it produces a complete machine language program, which can then ,e
e.ecuted.
#./ Code the ta03eUs statement for a sin-3e 3eve3 fre4uen"1?
!roc freB data8li,.dataset'
ta,le &ar' [here you can mention single &aria,le of multiple &aria,les seperated ,y space to get single
freBuency'
run'
#.2 What is the main differen"e 0etween rename and 3a0e3?
?. La,el is glo,al and rename is local i.e., la,el statement can ,e used either in proc or data step where
as rename should ,e used only in data step. M.+f we rename a &aria,le, old name will ,e lost ,ut if we
la,el a &aria,le its short name 5old name6 e.ists along with its descripti&e name.
#.? What are input dataset and output dataset options?
+nput data set options are o,s, firsto,s, where, in output data set options compress, reuse.(oth input
and output dataset options include keep, drop, rename, o,s, first o,s.
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
5&
SAS Faqs
www.arundathiinfotech.com
#.5 Cow "an u "reate =ero o0servation dataset?
$reating a data set ,y using the like clause.
e.: proc sBl'
create ta,le latha.emp like oracle.emp'
Buit'
+n this the like clause triggers the e.isting ta,le structure to ,e copied to the new ta,le. using this
method result in the creation of an empty ta,le.
#/: Cow "an u import .CS( fi3e in to SAS? te33 S1nta>?
To create $= file, we ha&e to open notepad, then, declare the &aria,les.
proc import datafile8D%:Wage.cs&Dout8sarath
d,ms8cs&
replace'
getnames8yes'
proc print data8sarath'
run'
#/9 What are a33 the ,DS pro"edure have u en"ountered?
Tracing and selecting the procedure #utput'
#D Trace on'
!roc steps\'
"un'
#D Trace off'
#D elect statement,
!roc steps\' #D elect output@o,Eect@list' "un'
#D #utput statement,
#D output output@o,Eect8 new A dataset'
#D html ,ody 8 SpathWmarine,ody.htmlT
$ontents 8 SpathWmarineT#$.htmlT
!age 8 S pathWmarinepage.htmlT
>rame8 SpathWmarineframe.htmlT'
\..
#D html close' #D rtf file 8 Sfilename.rtfT options'
#ptions like columns8n, ,odytitle, Adate and style.
#D rtf close'
imilarly
#D !df file 8 Sfilename.pdfT options' \\.. #D pdf close'
#/2 What is 1our e>perien"e with ,DS?
A. + ha&e used #D for creating files output formats "T> -T)L and !D> as per the reBuirement of
my manager. -T)L files could ,e posted on the we, site for &iewing or can also ,e imported into
word processors.
#D -T)L ,ody 8 apathR
$ontents8 apathR
>rame 8 apathR
#D -T)L close'
#D "T> >+L% 8 apathR
#D "T> close'
4hen we create "T> output we can copy it into word document and edit and resiGe it like word
ta,les.
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
55
SAS Faqs
www.arundathiinfotech.com
#/# What does the tra"e option do?
A. #D Trace is used to find the names of the particular output o,Eects when se&eral of them are
created ,y some procedure.
#D T"A$% #N'
#D T"A$% #>>'
#/& What are the three t1pes of Moin?
A. The three types of Eoin are inner Eoin, left Eoin and right Eoin.
The inner Eoin option takes the matching &alues from ,oth the ta,les ,y the #N option. The left Eoin
selects all the &aria,les from the first ta,le and Eoins second ta,le to it. The right Eoin selects all the
&aria,les of ta,le , first and Eoin the ta,le a to it.
NKL Cave 1ou ever used +!,C SQL for data summari=ation?
A. *es + ha&e used it for summariGation at times\
>or e.g if + ha&e to calculate the ma. &alue of (! for patients ?C? ?CM and ?CN then + use the ma.
5,pd6 function to get the ma.imum &alue and use group ,y statement to group the patients
accordingly.
#// Te33 me a0out 1our SQL e>perien"e?
A. + ha&e used the A2A$$% FL pass thru facility for connection with e.ternal data,ases and
importing ta,les from them and also )icrosoft access and e.cel files.
(esides this, lot of times + ha&e used !"#$ FL for Eoining ta,les.
#/2 ,n"e 1ou have had the data read into SAS datasets are 1ou more of a data step
pro-rammer or a +!,C SQL pro-rammer?
A. +t depends on what types of analysis datasets are reBuired for creating ta,les ,ut + am more of a
data step programmer as it gi&es me more fle.i,ility.
>or e.g creating a change from ,aseline data set for ,lood pressure sometimes + ha&e to retain certain
&alues \use arrays \.or use the first. @and last. &aria,les.
#/? What t1pes of pro-rammin- tas<s do 1ou use +!,C SQL for versus the data step?
A. !roc FL is &ery con&enient for performing ta,le Eoins compared to a data step merge as it does
not reBuire the key columns to ,e sorted prior to Eoin. A data step is more suita,le for seBuential
o,ser&ation@,y@o,ser&ation processing.
!"#$ FL can sa&e a great deal of time if u want to filter the &aria,les while selecting or u can
modify them \apply format\.creating new &aria,les , macro&aria,les\as well as su,setting the
data.
!"#$ FL offers great fle.i,ility for Eoining ta,les.
#/5 Cave u ever used +!,C SQL to read in a raw data fi3e?
A. No. + donRt think it can ,e used.
NUC Cow do 1ou mer-e data in +ro" SQL?
The three types of Eoin are inner Eoin, left Eoin and right Eoin. The inner Eoin option takes the matching
&alues from ,oth the ta,les ,y the #N option. The left Eoin selects all the &aria,les from the first ta,le
and Eoins second ta,le to it. The right Eoin selects all the &aria,les of ta,le , first and Eoin the ta,le a to
it.
!"#$ FL'
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
56
SAS Faqs
www.arundathiinfotech.com
$"%AT% TA(L% (#T- A
%L%$T A.!AT+%NT,
A.DAT% >#")AT8DAT%U. A DAT%, A.!UL%,
(.)%D, (.D#%, (.A)T >#")AT8X.?
>"#) =+TAL A +NN%" I#+N D#+N9 (
#N 5A.!AT+%NT 8 (.!AT+%NT6 AND
5A.DAT% 8 (.DAT%6
#"D%" (* !AT+%NT, DAT%'
FU+T'
#29 What are the statements in +ro" SQ3?
elect, >rom, 4here, 9roup (y, -a&ing, #rder.
!"#$ FL'
$"%AT% TA(L% -+9-(!!M A
%L%$T !AT+%NT, $#UNT 5!AT+%NT6 A N,
DAT% >#")AT8DAT%U., )A/5(!D6 A (!D-+9-
>"#) =+TAL
4-%"% !AT+%NT +N 5?C? ?CM ?CN6
9"#U! (* !AT+%NT
-A=+N9 (!D 8 $AL$ULAT%D (!D-+9-
#"D%" (* $AL$ULAT%D (!D-+9-'
Fuit'
#22 Wh1 and when do 1ou use +ro" SQ3?
!roc FL is &ery con&enient for performing ta,le Eoins compared to a data step merge as it does not
reBuire the key columns to ,e sorted prior to Eoin. A data step is more suita,le for seBuential
o,ser&ation@,y@o,ser&ation processing.
!"#$ FL can sa&e a great deal of time if u want to filter the &aria,les while selecting or we can
modify them, apply format and creating new &aria,les, macro&aria,les\as well as su,setting the
data. !"#$ FL offers great fle.i,ility for Eoining ta,les.
#2# What t1pe of -raphs have 1ou have -enerated usin- SAS?
A. + ha&e used !roc 9!L#T where + ha&e created change from ,aseline scatter plots. + ha&e also used
!roc L+>%T%T to create Oaplan@)eier sur&i&al estimates plots for sur&i&al analysis to determine
which treatment displays ,etter time@to@e&ent distri,ution.
#2& Cave 1ou ever used )!+LA%?
A. *%, + ha&e used the !"#$ 9"%!LA* point and click interface to integrate X graphs in one page.
4hich were produced ,y the reg procedure.
#2. What is the s1m0o3 statement used for?
A. ym,ol statement is used for placing sym,ols in the graphics output.
Associated &aria,les can specify the color, font and heights of the sym,ols displayed.
#2/ Cave 1ou ever used the annotate fa"i3it1? What is a situation when 1ou have had to use the
ANN,TAT fa"i3it1 in the past?
A. *es, + ha&e used the annotate facility for graphs. + ha&e used the annotate facility to position la,els
in the Oaplan@)eier sur&i&al estimates, where + had to specify the function as ala,elR and gi&e the .
and y co@ordinates and the position where this la,el is to ,e placed.
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
5'
SAS Faqs
www.arundathiinfotech.com
NUU . Appro.imately what date is represented ,y the A date &alue of @NKL7
a.01 jan 1959
#2? What purpose wou3d 1ou use the !TA'N statements?
In order to carry forward the value of a Variable from one iteration to the other iteration of the
dataste.
#25 What is Stored "omp3ied $a"ro?
! macro which is stored after it is comlied these macros are used in roduction level jobs" they will
overcome the comilation overhead of autocall macros.
#?: What is a sas data set and how it is or-ani=ed?
! sas data set is a table in oracle.
#?2 What are the different t1pes of input st13es and what is the differen"e 0etween simp3e
3ist input and advan"ed 3ist input st13e?
a. #he different inut styles are
i$List inut style" ii$%olumn inut style iii$!dvanced list inut syle
iv$&ormatted inut style v$Named inut style.
'imle list inut style is used to read the standard data with delimiters where as !dvanced list
inut style is used to read the non(standard data with delimiters.
#?# What is the diff 0etween datastep and pro" step
)ataste is used to create datasets where as roc ste is used to rocess the datasets.
#?& Whi"h information is stored in des"riptive portion of a dataset?
*ost en+ine details" all the variables alon+ with their data to which they belon+ that is either
they are character" numeric", when it was created and when it was last modified ,any informats.
#?.. What is the si-nifi"an"e of retain statement in sas data step pro-ram?
-etain statement is used to carry forward the value from one iteration to the other iteration of the
data ste.
#?/. Cow "an 1ou appendO"on"atenate 2 or more sas datasets?
.y usin+ set statement "roc aend rocedure or else usin+ mer+e statement.
#?2 Cow "an 1ou "ompress sas datasets?
Usin+ %/01-2''3 otion
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
5Q
SAS Faqs
www.arundathiinfotech.com
#?? Cow "an 1ou read sas o0servation from 9:: to 2::?
usin+ firstobs3100 obs3400
#?? Whi"h sas fun"tion returns the words in a strin-
Usin+ scan function
#?5 Cow "an 1ou find the e>isten"e of a su0str in a -iven strin-
Usin+ inde5 function
#5: Cow "an 1ou rep3a"e a su0strin- in a -iven strin-
'ubstr with ri+ht hand side
NJ? Cow "an 1ou find no. ,f da1s@ no.of 1ear@ months 0etween an1 two dates?
Usin+ the intc6 function
#52 what is the si-nifi"an"e of 1ear"utoff; optionW
7e can chan+e the base year from 1940 to our own choice deendin+ on the re8uirement.
#5# Cow to "ontro3 pa-e num0ers on sas report
Usin+ the no number otion.
99: What is the advanta-e of sum statement over retain statement?
a. In sum statement we need not initiali;e the variable" as it is re8uired in retain statement.
#5. What is the diff. Eetween ifJthenJe3se and su0strin- if
a. In subsettin+ if" if the condition is true then only the control +oes to the ne5t statement after the
subsettin+ if or else it +oes to the startin+ of the ste..where as this is not true in the if(then(else.
99< what is the differen"e 0etween +ro" Anova And +ro" $eans?
Ans. AN#=A &s )%AN
NJU What D'$ fun"tion do in Arra1s ? What is meant 01 n"r1pt?
Ans.D+)5array_name6
D+)5array_name6 returns the num,er of elements in the array named
;array_name;.
(e specific on the Buestion on encrypt HHHHHH
+f it is the dataset option you were asking a,out, then thru encrypt option we can set a password for
read2write options for the newly created dataset. +t can later ,e read2edited only after specifying the
password.
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
5(
SAS Faqs
www.arundathiinfotech.com
#5? what is pdv how one "an store the data@ where we wi33 use in sas? in s43 or ma"ros?
Ans.!D= tands for !rogram Data =ector.. +ts a internal construct of A when processing any data.
Understanding the concept of !D= can help a programmer write more efficient A !rograms.There
is a paper ,y the title ;ecret life of the Datastep; which was presented in one of the A User
9roup +nternational sessions a,out ?C years ago which e.plains this concept ,eautifully.
#55 Code the ta03e statement for a sin-3eJ3eve3 6most "ommon8
fre4uen"1.?
The statement for single@le&el.
DATA )A".>"%FT%T'
%T (A.A)!%"'
+!,C F!Q DATA 8)A".>"%FT%T'
TA(L% A9%'
!UN'
&:: Code the ta03e statement to produ"e a mu3tiJ3eve3 Fre4uen"1?
The statement for multile&el.
DATA )A".>"%FT%T'
%T (A.A)!%"'
+!,C F!Q DATA 8)A".>"%FT%T'
TA(L% A9% [ gender'
!UN'
&:9 What happens in a oneJonJone mer-e? When wou3d 1ou use
one?
Ans:+f you want to merge two data set that ha&e different
&aria,le and only one &aria,le as a common &aria,le
with that uniBue &aria,le we can merge the data set
with one@on@one merge.
&:2 What is the pro03em with mer-in- two data set that have
varia03e with the same name 0ut different data?
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
60
SAS Faqs
www.arundathiinfotech.com
Ans:The second data set &alue will o&erwrite the &alue
of the first data set.
Arundathi (n'otech,
# 605, Annapurna Block, Adithya ncla!e, Ameerpet, "yd. #h.$o%0&0%66'5'5&5,
(0)0*++'5+
6+