You are on page 1of 4

Print

Quiz,Lesson2:WorkingwithSASPrograms

YourScore:
80%

Congratulations!Yourscoreof80%indicatesthatyou'vemasteredthetopicsin
thislesson.Ifyou'dlike,youcanreviewthefeedbackforeachquestion.

1.Howmanystepboundariesdoesthisprogramcontain?
datawork.staff
lengthFirst_Name$12
Last_Name$18
Job_Title$25
infile"&path/newemployees.csv"dlm=','
inputFirst_Name$Last_Name$
Job_Title$Salary
run
procprintdata=work.staff
run
procmeansdata=work.staff
varSalary
run
a.
b.
c.
d.

four
five
six
seven

Youranswer:d
Correctanswer:c
RUN,QUIT,DATA,andPROCstatementsfunctionasstepboundaries,whichdetermine
whenSASstatementstakeeffectandindicatetheendofthecurrentsteporthebeginningofa
newstep.
Review:SASProgrammingSteps

2.WhichofthefollowingisaSASsyntaxrequirement?
a.
b.
c.
d.
e.

Begineachstatementincolumnone.
Putonlyonestatementoneachline.
Separateeachstepwithalinespace.
Endeachstatementwithasemicolon.
PutaRUNstatementaftereveryDATAorPROCstep.

Youranswer:d
Correctanswer:d
SASstatementsusuallybeginwithanidentifyingkeyword,andtheymustendwitha
semicolon.AlthoughitisrecommendedtoendstepswithaRUNstatement,itisoptional.The
otherlisteditemsarerelatedtoformattingyourprogramstomakethemeasiertoread.
Review:CharacteristicsofSASPrograms

3.Whichofthefollowingstepsistypicallyusedtogeneratereportsandgraphs?
a.
b.
c.
d.

DATA
PROC
REPORT
RUN

Youranswer:b
Correctanswer:b
PROCstepsaretypicallyusedtoprocessSASdatasets(thatis,generatereports,graphs,
andstatistics).
Review:UnderstandingSASPrograms

4.Doesthiscommentcontainsyntaxerrors?
/*
Reportcreatedforbudget
presentationrevisedOctober15.
*/
procprintdata=work.newloan
run
a.
b.
c.
d.

No.Thecommentiscorrectlyspecified.
Yes.Everycommentlinemustendwithasemicolon.
Yes.Thecommenttextincorrectlybeginsonlineone.
Yes.Thecommentcontainsasemicolon,whichcausesanerrormessage.

Youranswer:a
Correctanswer:a
Ablockcommentbeginswithaforwardslashandanasterisk,followedbyyourcommenttext,
andendswithanasteriskandforwardslash.Ablockcommentcanbeanylength,andcan
containsemicolons.
Review:TypesofComments

5.Whatresultwouldyouexpectfromsubmittingthisstep?
procprintdata=work.newsalesemps
run
a.
b.
c.
d.

alistreportofthework.newsalesempsdataset
anerrormessageinthelog
asummaryreportofthework.newsalesempsdataset
thecreationofatemporarydatasetcalledwork.newsalesemps

Youranswer:a
Correctanswer:b
Thereisamissingsemicolonfollowingthedatasetname.Whenthisstepruns,SASwill
interpretthewordRUNasanoptioninthePROCPRINTstatement(becauseofthemissing
semicolon).Asaresult,thePROCPRINTstepwillnotexecuteandanerrormessagewillbe
displayedinthelog.

Review:WhatIsaSyntaxError?

6.SASallowseithersingleordoublequotationmarks.Ifyoubeginwithasinglequotationmark,
youcanendwithadoublequotationmark.
a. True
b. False
Youranswer:b
Correctanswer:b
Also,althoughSASallowseithersingleordoublequotationmarks,youcan'tmixthetypes.If
youbeginwithasinglequotationmark,youmustendwithasinglequotationmarkotherwise,
SASconsidersthequotationmarksunbalanced.
Review:UnbalancedQuotationMarks

7.Whathappensifyousubmitthefollowingprogram?
porcprintdata=work.newsalesemps
run
a. SASdoesnotexecutethestep.
b. SASassumesthatthekeywordPROCismisspelledandexecutesthePROCPRINT
step.
Youranswer:b
Correctanswer:b
ThelogwillindicatethatSASassumedthatthekeywordPROCwasmisspelled,correctedit
temporarily,andexecutedthePROCstep.
Review:ViewingandCorrectingSyntaxErrors

8.Wheredoglobalstatementsappear?
a.
b.
c.
d.

anywhereinaSASprogram
onlyinsideDATAsteps
onlyinsidePROCsteps
onlyinsideDATAstepsorPROCsteps

Youranswer:a
Correctanswer:a
GlobalstatementscanappearanywhereinaSASprogrameitherinsideoroutsideofDATA
andPROCstepsandcanaffectmorethanonestep.
Review:SASProgrammingSteps

9.SASpermitsyourprogramstobefreeformat.
a. True
b. False
Youranswer:a

Correctanswer:a
SASstatementsarefreeformat.Inotherwords,theycanbeginandendanywhere.InSAS,
youcanhaveasmuchoraslittlewhitespaceasyouwant.AccordingtoSASsyntaxrules,
youcanbeginorendastatementinanycolumnandspanmultiplelines.Youcanalsoplace
multiplestatementsononeline,andunquotedvaluescanbelowercase,uppercase,ormixed
case.
Review:SASProgramStructure

10.AcommentistextinyourprogramthatSASprocessesalongwiththeotherSASstepsinyour
program.
a. True
b. False
Youranswer:b
Correctanswer:b
AcommentistextinyourprogramthatSASignoresduringprocessing,butwritestotheSAS
log.
Review:UsingSASComments

Close

Copyright2016SASInstituteInc.,Cary,NC,USA.Allrightsreserved.

You might also like