Advanced SAS InterviewQuestions You'll Most Likely BeAsked Job Interview QuestionsSeries www.vibrantpublishers.com ***** Advanced SAS InterviewQuestions You'll Most Likely Be Asked Published by Vibrant Publishers atSmashwords Copyright 2021 Vibrant Publishers,USA. Smashwords Edition, LicenseNotes This ebook is licensed for yourpersonal use only. This ebook may not be re-sold or given away toother people. If you would like to share this book with anotherperson, please purchase an additional copy for each recipient. Ifyoure reading this book and did not purchase it, or it was notpurchased for your use only, then please return to Smashwords.comand purchase your own copy. Thank you for respecting the hard workof this author.
This publication is designed toprovide accurate and authoritative information in regard to thesubject matter covered. The author has made every effort in thepreparation of this book to ensure the accuracy of the information.However, information in this book is sold without warranty eitherexpressed or implied. The Author or the Publisher will not beliable for any damages caused or alleged to be caused eitherdirectly or indirectly by this book. Vibrant Publishers books areavailable at special quantity discount for sales promotions, or foruse in corporate training programs. For more information pleasewrite to Please email feedback / corrections(technical, grammatical or spelling) to To access the complete catalogue ofVibrant Publishers, visit www.vibrantpublishers.com ***** Tableof Contents ***** Advanced SAS InterviewQuestions Review these typical interviewquestions and think about how you would answer them. *****
1: When PROCSQL is recommended over SAS DATA steps? Answer: For bulkoperations, PROC SQL Joins are considered better performing thanthe DATA step Merge. *****
1: When PROCSQL is recommended over SAS DATA steps? Answer: For bulkoperations, PROC SQL Joins are considered better performing thanthe DATA step Merge.
This is because the joins do not require thedata to be sorted based on the keys whereas the merge requires itto be sorted. But a data step merge is better when you need toaccess the observations one by one. PROC SQL lets you filter,modify and apply formats to the variables easily. You can createmacro-variables and subset the data using PROC SQL. 2: Can yousubset using both WHERE and IF statements based on a newly derivedvariable? Answer: No. Forsubsetting based on a newly derived variable only IF statement canbe used.
If you use WHERE, it will give an error. But you can use anewly created variable to subset along with WHERE. 3: How wouldyou compare two tables with PROC SQL? Answer: The setoperator EXCEPT is used to compare two tables in PROC SQL. When youuse it with two different tables, it returns all rows from thefirst table which are not there in the second table.Example, ProcSQL; Select * fromEmpfile; EXCEPT Select * fromMgrfile; quit; This willreturn all records from Empfile that are not in theMgrfile. 4: How does%LOCAL and %GLOBAL differ? Answer: %LOCAL is usedto create a local macro variable which will be accessible to thecurrent macro till it completes execution. %GLOBAL is used to create a globalmacro variable which will be accessible throughout a session acrossthe macros. %GLOBAL is used to create a globalmacro variable which will be accessible throughout a session acrossthe macros.
It will not be accessible once the sessionends. 5: How PROCSQL differs from other PROC statements in SAS? Answer: Proc SQL istotally different from the usual SAS Procedures in the followingways: a) SASprocedures require a RUN statement while PROC SQL does not requireit. All PROC SQL statements are RUN automatically. b) PROC SQLwill RUN even after a step is submitted. So, you need toexclusively submit the data step or proc step or issue a quitstatement to stop the procedure. c) PROC SQLconsists of many statements that allows clauses whereas the SASprocedures do not have this option. Example.: Heres an example for PROC SQL which contains3 statements, PROC SQL, SELECT and QUIT. Example.: Heres an example for PROC SQL which contains3 statements, PROC SQL, SELECT and QUIT.
The SELECT statementcontains select, FROM, WHERE and ORDER BY clauses. procsql; selectAuthType, SlNum, AuthorName frommylib.table1 where SlNum< 25000 order byAuthType; quit; 6: Supposeyou are generating a report from the data setexam.questionset1using PROC SQL. You wish to displaythe name of the column author as writer in the report. How doyou write the query to modify the report? Answer: The followingprogram generates a report from exam.questionset1 using PROCSQL. The column named author is assigned an aliaswriter in the report using the keyword AS. procsql; select type,slno, author as writer fromexam.questionset1; quit; 7: Whilegenerating a report using PROC SQL, how do you sort the rows indescending order of any particular column? Answer: The ORDER BYclause is used in the SELECT statement of PROC SQL to sort the rowsin the output according to the values of a particular column. procsql; select type,slno, author as writer fromexam.questionset1; quit; 7: Whilegenerating a report using PROC SQL, how do you sort the rows indescending order of any particular column? Answer: The ORDER BYclause is used in the SELECT statement of PROC SQL to sort the rowsin the output according to the values of a particular column.
Bydefault, ORDER BY clause sorts the rows in the ascending order. Therows can be sorted in the descending order of any column byspecifying the keyword, desc, after the columnname. Example.: The following program selects type,slno and author for all the rows having slno lessthan 30000. In the output, the rows are sorted according to thedescending values of slno. procsql; select type,slno, author fromexam.questionset1 where slno<30000 order by slnodesc; quit; 8: What isreferred to as qualifying a column name? Answer: Qualifying acolumn name refers to the process of prefixing the SAS data setname to a column name. This is done mostly in those situationswhere you need to select the data from two data sets and the twodata sets have the same named columns.
If you want to include oneof the same named columns, then you will have to prefix the name ofthe data set from which you wish to take the column to the columnname in the query. Example: The following PROC SQL query joins two datasets exam.set1 and exam.set2. Both the data setscontain the same column slno. So, to indicate the data setfrom which the value of slno is to be read, the name of thedata set is prefixed to the column name in the SELECT clause. Thisis referred to as qualifying the column name. Example: The following program selects all the columnsfrom the data set exam.questionset1. procsql; select* fromexam.questionset1 quit; 10: What isthe significance of FEEDBACK option? Answer: The FEEDBACKoption is a debugging tool which helps us to see what is beingsubmitted to the processor. procsql; select* fromexam.questionset1 quit; 10: What isthe significance of FEEDBACK option? Answer: The FEEDBACKoption is a debugging tool which helps us to see what is beingsubmitted to the processor.
When asterisk (*) is used with SELECTclause, FEEDBACK option is used in the PROC SQL statement, which inturn writes the list of column names to SAS log. Example: In the following program FEEDBACK option isused in the PROC SQL statement. This causes a detailed list ofcolumn names (type, slno and author) to be written toSAS log. proc sqlfeedback; select* fromexam.questionset1 quit; 11: Whileusing PROC SQL, how do you limit the number of rows which isdisplayed in the output? Answer: The OUTOBS=option can be used in the PROC SQL statement to limit the number ofrows displayed. OUTOBS= option is similar to OBS= data setoption.
Next page