new good n easy base sas interview questions by topic

55
Kelly Technologies Flat No: 212, 2nd floor, Annapurna Block, Aditya Enclave, Ameerpet,Hyderabad-16. E-mail: [email protected] Tel: +9140 6462 6789, +91 998 570 6789 Online and Classroom Trainings for SAS, SAS BI Base Sas / Advance SAS Interview Questions 1. How many data types are there in SAS? Sas has only Two Data Types Character Numeric Read class notes to understand the storage values / length / missing values representation 2. If a variable contains only numbers, can it be character data type? Also give example? Yes, character data type can store Letters(A-Z,a-z) or Number (0-9) or Spl Char(!@#$%^&*()) or Combination of these. If Numbers are stored as character data type then we cannot perform any mathematical expression. Addl Information: To perform mathematical expressions then use INFORMAT to convert into standard numeric data value and numeric data type. 3. If a variable contains letters or special characters, can it be numeric data type? Not possible, it can only be character data type. 4. How to read excel worksheet in SAS? Import Procedure 5. What version of SAS are you currently using? Current Version: SAS 9.3

Upload: sindhusai24

Post on 21-Jul-2016

37 views

Category:

Documents


4 download

DESCRIPTION

New version of base sas interview questions

TRANSCRIPT

Page 1: New Good N easy Base Sas Interview Questions by Topic

Kelly Technologies

Flat No: 212, 2nd floor,Annapurna Block, Aditya Enclave,Ameerpet,Hyderabad-16.E-mail: [email protected]: +9140 6462 6789, +91 998 570 6789Online and Classroom Trainings for SAS, SAS BI

Base Sas / Advance SAS Interview Questions

1. How many data types are there in SAS?Sas has only Two Data TypesCharacter Numeric

Read class notes to understand the storage values / length / missing values representation

2. If a variable contains only numbers, can it be character data type? Also give example?Yes, character data type can store Letters(A-Z,a-z) or Number (0-9) or Spl Char(!@#$%^&*()) or Combination of these. If Numbers are stored as character data type then we cannot perform any mathematical expression.

Addl Information: To perform mathematical expressions then use INFORMAT to convert into standard numeric data value and numeric data type.

3. If a variable contains letters or special characters, can it be numeric data type?Not possible, it can only be character data type.

4. How to read excel worksheet in SAS?Import Procedure

5. What version of SAS are you currently using?Current Version: SAS 9.3

6. Describe your familiarity with SAS Formats / Informats.FORMAT – presentation / display / appearance of a value for the end user to

understand the data better NUM NUM Race Race 1 USA

Formats are created using FORMAT PROCEDURE(USER DEFINED FORMATS)

If formats are available with sas system(in-built) it is SYSTEM DEFINED FORMAT (dollar14.2, comma10.2, date9., mmddyy10.,time8..)

Page 2: New Good N easy Base Sas Interview Questions by Topic

Kelly Technologies

Flat No: 212, 2nd floor,Annapurna Block, Aditya Enclave,Ameerpet,Hyderabad-16.E-mail: [email protected]: +9140 6462 6789, +91 998 570 6789Online and Classroom Trainings for SAS, SAS BI

INFORMAT – converting non standard data value into standard valueIf reading data from raw data file we use INFORMAT Statement,If reading data from existing variable which consists of non standard data

then use INPUT and PUT functions

Mathematical expressions cannot be performed on character data type so use INFORMAT to convert non standard to standard to create mathematical expressions.

7. Data statement options at least any 3 options.Options statement; (System Options)Data libref.outputdtataset(datasetoptions);

Set libref.inputdataset(datasetoptions);Statements;

Run;

Drop = , Keep = , Rename= , Where = , Firstobs = , Obs = Drop, Keep, Where and Rename can also be used as statements

8. What system options are you familiar with?- SAS system options are initialized with default settings when SAS is invoked - an option that affects the processing of an entire SAS program or interactive SAS session from the time the option is specified until it is changed.

SAS options:Options nodate notime linesize= pagesize = ;Options date time ;

Macros Options:Options mlogic merror mprint symbolgen sasautos= mautosource mcompilenote;

9. For what purposes do you use DATA _NULL_?Data _Null_;

Set libref.inputdataset;Transformations;

Run;

Page 3: New Good N easy Base Sas Interview Questions by Topic

Kelly Technologies

Flat No: 212, 2nd floor,Annapurna Block, Aditya Enclave,Ameerpet,Hyderabad-16.E-mail: [email protected]: +9140 6462 6789, +91 998 570 6789Online and Classroom Trainings for SAS, SAS BI

10. Name at least five compile time statements?During Compilation of Data Step

syntax scan SAS source code translation to machine language definition of input and output files creation of tools:

i. input buffer (if reading any non-SAS data),ii. Logical Program Data Vector (LPDV),

iii. and data set descriptor information determining variable attributes for output SAS data set capturing variables to be initialized to missing

data work.outputdataset;set libref.inputdataset;drop ;keep ; rename ;length;format;informat;arrayby

run;

Compile Time Statements: Location irrelevant:

drop, keep, renamelabel`retain

Location critical:lengthformat, informatarraybywhere

Page 4: New Good N easy Base Sas Interview Questions by Topic

Kelly Technologies

Flat No: 212, 2nd floor,Annapurna Block, Aditya Enclave,Ameerpet,Hyderabad-16.E-mail: [email protected]: +9140 6462 6789, +91 998 570 6789Online and Classroom Trainings for SAS, SAS BI

11. State different ways of getting data into SAS?Methods for getting your data into SAS can be put into four general categories:

Entering data directly into SAS data sets Creating SAS data sets from raw data files (infile and input statements) Converting other software’s data files into SAS data sets (proc sql connect

to database files) Reading other software’s data files directly ( Proc Sql Pass-Through

Facility)

12. Can you state some special input delimiters?DLM= or Delimiter =

Infile Dlm=’@,’ – each spl char is individual delimiterInfile Dlmstr = ‘-/-’ – group the spl characters and search in raw data file together

DLMSTR = This option enables programmers to specify a multi-character string as a delimiter. For example, DLMSTR="-/-" treats these three characters, in this order, as a delimiter. Prior to this option, each individual character specified in the DLM= option would have been treated singularly as a delimiter.

13. Which gets applied first when using the keep= and rename= data set options on the same data set?

Dataset options applied first and later dataset statements

DROP= and KEEP= options are applied before the RENAME= option.Next, DROP and KEEP statements are applied, followed by the RENAME statement.

14. What option in PROC FORMAT allows you to create a format from an input control data set rather than VALUE statement?

Proc format;Value $charfmtname;

‘Search for a value’ = ‘Present the value’;

Proc format cntlin=libref.inputdataset;Run;

CNTLIN= Specify a SAS data set from which PROC FORMAT builds informats or formats

Page 5: New Good N easy Base Sas Interview Questions by Topic

Kelly Technologies

Flat No: 212, 2nd floor,Annapurna Block, Aditya Enclave,Ameerpet,Hyderabad-16.E-mail: [email protected]: +9140 6462 6789, +91 998 570 6789Online and Classroom Trainings for SAS, SAS BI

15. State different ways of combining sas datasets(data step statement)?Concatenation (Vertical)Interleaving (Vertical)One to One Reading (Horizontal)One to One Merging (Horizontal)Match Merging (Types : one to one, many to many, one to many or many to one)

(Horizontal)Update (Horizontal)Modify (Horizontal)

16. What is Concatenation ? what is Interleaving ? Difference between Concatenation and Interleaving?Concatenation – combines observations from multiple input datasets into one single output dataset in the order in which it is defined (it does not sort the data on the output dataset)

Interleaving – is similar to concatenation but while concatenation it sorts the data on the key variable specified in BY Statement

17. Types of Merge? How to merge two data sets? - One to One Reading (without key variable)- One to One Merging (without key variable)- Match Merging(with key variable)

* One to One * One to Many * Many to Many

18. What is the difference between One to One Merge and Match Merge? Give example also.

One to One Merge – it merges the first observation from first dataset with the same observation number from subsequent dataset two

Match Merge – merges data with the key variable values on both the datasets but not with the relative order of the observation number

Page 6: New Good N easy Base Sas Interview Questions by Topic

Kelly Technologies

Flat No: 212, 2nd floor,Annapurna Block, Aditya Enclave,Ameerpet,Hyderabad-16.E-mail: [email protected]: +9140 6462 6789, +91 998 570 6789Online and Classroom Trainings for SAS, SAS BI

19. How can you combine two datasets based on the relative position of rows in each data set; that is, the first observation in one data set is joined with the first observation in the other, and so on?

One to One Reading (if both datasets have equal number of observations) One to One Merging without Key Variable (if datasets have unequal

number of observations

20. What would be the format of Revenue in resulting dataset?data concat;

set a b;run;

Format of variable Revenue in dataset a is dollar10.2 and format of variable Revenue in dataset b is dollar12.2

Ans: Dollar10.2

21. If you have two datasets you want to combine them in the manner such that observations in each BY group in each data set in the SET statement are read sequentially, in the order in which the data sets and BY variables are listed then which method of combining datasets will work for this?Ans: Interleaving

22. It is possible to use the MERGE statement without a BY statement? Explain?Yes a merge statement can be use without a BY statement if you would like to

Merge by the observation numbers (one to one reading and one to one merging)

23. I have a dataset concat having variable a b & c. How to rename a b to e & f?Renaming a variable using Rename as dataset option or Statement:Data concat (rename=(a=e b=f));

Set concat;Run;

24. What is difference between appending and concatenating? Or Append and set difference

Page 7: New Good N easy Base Sas Interview Questions by Topic

Kelly Technologies

Flat No: 212, 2nd floor,Annapurna Block, Aditya Enclave,Ameerpet,Hyderabad-16.E-mail: [email protected]: +9140 6462 6789, +91 998 570 6789Online and Classroom Trainings for SAS, SAS BI

25. How many datasets can be merged at a time using MERGE statement? There is not limit to number of datasets that can be merged.

26. What does the difference between combining 2 datasets using multiple SET Statement and MERGE statement with common key variable or without common key variable?

Set and Merge DifferenceWhile the SET statement reads observations from one data set at the time, the MERGE statement reads from two or more data sets simultaneously

27. How do I remove duplicate observations from my data set?1. You can use Proc Sort with option Nodup to remove duplicate observations for

Page 8: New Good N easy Base Sas Interview Questions by Topic

Kelly Technologies

Flat No: 212, 2nd floor,Annapurna Block, Aditya Enclave,Ameerpet,Hyderabad-16.E-mail: [email protected]: +9140 6462 6789, +91 998 570 6789Online and Classroom Trainings for SAS, SAS BI

all variables or with option NodupKey to remove duplicate observations for By key variables only from your data set.2. Dupout is a new option in Proc Sort. It names a SAS data set that will contain the duplicate records eliminated from the data  set.3. You can also use FIRST. and LAST. variables in a data step to remove duplicate observations.

* Noduprecs deletes duplicate records from the input datset;* DUPOUT Option stores the duplicate deleted records into this dataset specified;proc sort data = libref.inputdataest nodup dupout=libref.outputdataset;

by vars;run;

* Nodupkey option removes duplicate observations only on the key variables specified in by statement;proc sort data = libref.inputdataest nodupkey;

by var1 var2;run;

* Remove Duplicate observations using data step statement then use by group processing with first. and last.;

data libref.outputdataset; set libref.inputdataet;by locaton jobcode;if first.jobcode ; * First record;

run;

* Removing duplicate observations using proc sql with distinct keyword;proc sql;

select distinct jobcodefrom airline.crew;

quit;

Page 9: New Good N easy Base Sas Interview Questions by Topic

Kelly Technologies

Flat No: 212, 2nd floor,Annapurna Block, Aditya Enclave,Ameerpet,Hyderabad-16.E-mail: [email protected]: +9140 6462 6789, +91 998 570 6789Online and Classroom Trainings for SAS, SAS BI

proc sql;select distinct *from airline.crew;quit;

28. How would you delete duplicate observations?NODUP option in proc sort

29. How would you delete observations with duplicate keys?NODUPKEY option in proc sort

30. How to display duplicated observations in a data using base sas?There are two ways to display duplicate observations.1) In data step, using first.var and last.var2) Using proc sort with option dupout option

31. Rename= option and Rename as a Statement?Rename as a datset option can be specified on both input as well as output datasetRename as a statement when specified applies only to the variables on all the

output dtasets

32. What is difference between proc means and proc summary?Proc means by default generates an output reportProc summary by default generates an output dataset

Proc means with noprint option is similar to proc summary

33. What is use of output statement?Output statement forceabily sends the obs to the output dataset in the location

specified in the code

Data work.flightattds work.pilots;Set libref.inputdataset;If jobcode = ‘FLTAT’ then output work.flightattds;

Run;

34. What is the purpose of trailing @ and @@?

Page 10: New Good N easy Base Sas Interview Questions by Topic

Kelly Technologies

Flat No: 212, 2nd floor,Annapurna Block, Aditya Enclave,Ameerpet,Hyderabad-16.E-mail: [email protected]: +9140 6462 6789, +91 998 570 6789Online and Classroom Trainings for SAS, SAS BI

Double Trailing @@ - when reading data from raw data file if the data consists of multiple observations per record then use double trailing on input statement

Single Trailing @ - when reading data values conditionally from raw data file and loading to output dataset then use single trailing to hold the data in memory and load the values for all the variables.

35. What are Report Procedures? or What are Summary Procedures ? Can you name some report procedures that you have used in your project and what kind of reports you have generated? or Name few Report Procedures ?

For decision making Report Procedures or Summary procedures are used in any functional domain

Types of Report Procedures are:- Frequency Procedure- Means Procedure- Tabulate Procedure- Summary Procedure- Univariate Procedure- Report Procedure

36. What is Freq Procedure? How many types of Freq procedures are there?Frequency Procedure – generates the freq counts on the values inside the variable

specified or the total number of observations with the duplicate values

- One Way Freq - generates freq counts on each single variable specified separately

- Two Way Freq – generates cross tabular reports (with one variable on the row and another variable on the column)

- N Way Freq - is similar to Two Way Freq procedure with By Statement, which can alternatlively written in N Way Freq Procedure with page-exp*row-exp*col-exp variables

37. What is the default report result of One Way Freq Procedure? Can you define few Statements and Options in One Way Freq Procedure?By default the One Way Freq Proc generates freq counts on all the variables (i.e.

Page 11: New Good N easy Base Sas Interview Questions by Topic

Kelly Technologies

Flat No: 212, 2nd floor,Annapurna Block, Aditya Enclave,Ameerpet,Hyderabad-16.E-mail: [email protected]: +9140 6462 6789, +91 998 570 6789Online and Classroom Trainings for SAS, SAS BI

char and num data type) from the input dataset.

The measures generated are FeqCnts / CumFreq / Percent / CumPercent Proc freq data = libref.inputdataset nlevels;

Table var1 / nocum nopercent out=libref.outputdataset;Weight anavar;By grpvar1; Where condition;Format varname fmtname.;

Statements: table / weight / by / format / where Options: nlevels / weight / nocum nopercent / out = libref.outputdataset

38. What type of data variables can be specified on tables statement in proc frequency?Char or Numeric Data TYpe

39. What is the purpose of Table, Weight, By in One Way / Two / N way Freq procedures?

40. What is Proc Freq's default behavior for handling missing values?The variable specified on TABLE statement in PROC FREQ by default generates

only on non missing values and prints a message at the bottom of the report with number of missing values

In order to print even the missing value on to the output report use MISSING Option in table statement

41. Describe CROSSLIST option in TABLES statement?CROSSLIST option in Tables statement in Proc Two-Way Freq converts cross tabulation report into listing report

42. Proc Mean’s procedure in detail?Means procedure by default generates the default descriptive stats i.e. N Min Max

Mean Std onto output report on all the numeric variables and across all the observations grouped together form input dataset

Page 12: New Good N easy Base Sas Interview Questions by Topic

Kelly Technologies

Flat No: 212, 2nd floor,Annapurna Block, Aditya Enclave,Ameerpet,Hyderabad-16.E-mail: [email protected]: +9140 6462 6789, +91 998 570 6789Online and Classroom Trainings for SAS, SAS BI

43. What are the default statistics generated by Means Procedure?

The default stats generated by proc means is : N Min Max Mean Std

44. By default on which variable data types the means procedure generates descriptive statistics?By default proc means generates descriptive stats on all the numeric variables

form the input dataset

45. How to classify the data in proc means and restrict on specific numeric variables to print descriptive statistics?By default proc means generates descriptive stats on all the numeric variables and

grouping all the observations together.

In order to generate descriptive stats on specific numeric variables from input dataset use VAR statement with analysis variables(numeric variables).

In order to generate descriptive stats by grouping the data then use CLASS statement in means procedure

proc means data = libref.inputdataset;Var anavar1 anavar2;Class var1 var2 var3;

Run;

Var statement accepts only numeric data type variables.CLASS Statement accepts both character as well as numeric data type variables

46. How to override the default statistics in proc means? How to Store the results into output dataset? Or

47. How to overwrite the default statistics in Means Procedure with the User defined Statistics?Proc means statement statement define the descriptive stats that is to be printed by

Overriding the default stats

Page 13: New Good N easy Base Sas Interview Questions by Topic

Kelly Technologies

Flat No: 212, 2nd floor,Annapurna Block, Aditya Enclave,Ameerpet,Hyderabad-16.E-mail: [email protected]: +9140 6462 6789, +91 998 570 6789Online and Classroom Trainings for SAS, SAS BI

proc means data = libref.inputdataset Stderr Std Median Var;var anavar;

run;

48. What is Means Procedure ? What is the default report of Means Proc?

49. How to create output dataset from Means Procedure?

50. What is Maxdecd= value in proc means?Maxdec=value in proc means restricts on how many decimal places to be printed

in output report

51. How does Means Procedure handle missing values?(N and Nobs prints missing values based on the anavar)N – print total number of observations with both missing as well as non missing

valuesNOBS – if class statement is specified in proc means it generates the total number

of observations from input dataset with both missing as well as non missing values

MISSING – option prints the missing values on the variables specified in CLASS Statement onto output report

52. What is Nobs / N / Missing options in proc means?53. When creating an output dataset from Means Procedure it generates _Type_ /

_Freq_ ? Can you explain what does this mean?

When means procedure results are stored into output dataset by default it creates two variables _Type_ and _Freq_.

_Type_ - stores the numeric values that is the numer of ways or combination in which the data is stored based on the class statement in proc means

_Freq_ - stores the total number of observations considered for each combination with both missing and nonmissing values

Page 14: New Good N easy Base Sas Interview Questions by Topic

Kelly Technologies

Flat No: 212, 2nd floor,Annapurna Block, Aditya Enclave,Ameerpet,Hyderabad-16.E-mail: [email protected]: +9140 6462 6789, +91 998 570 6789Online and Classroom Trainings for SAS, SAS BI

proc means data = libref.inputdataset;var salary;class location jobcode;

run;

_Type_ 0 – combinataion across all the observations1 – combination across each jobcode2 – combination across each location3 – combination across each location and jobcode (NWAY)

54. Why do we use NWAY option in proc means?When proc means results are stored into output dataset it stores in multiple

combinations(_Type_) to store in the combination specified in CLASS statement then use NWAY option on proc means

proc means data = libref.inputdataset NWAY;var salary;class location jobcode;output out = libref.outputdataset;

run;

55. What is the difference between Means / Summary / Univariate Procedures?Means procedure generates by default descriptive stats onto output reportSummary procedure generates by default output dataset with descriptive stats

specified by the userUnivariate procedure generates by default onto output report all the stats that is

possible

56. Is there any restriction on number of variables to be considered on Var Statement and Table statement in Means Procedure?No restriction on number of variables to be specified on var and class statement

but atleast one variable to be specified

proc means data = libref.inputdataset NWAY;var salary;

Page 15: New Good N easy Base Sas Interview Questions by Topic

Kelly Technologies

Flat No: 212, 2nd floor,Annapurna Block, Aditya Enclave,Ameerpet,Hyderabad-16.E-mail: [email protected]: +9140 6462 6789, +91 998 570 6789Online and Classroom Trainings for SAS, SAS BI

class location jobcode;output out = libref.outputdataset;

run;

57. When do we use Proc Tabulate ? Features of Tabulate Procedure ?58. What is Class / Var / Table statement in Proc Tabulate?59. Can numeric variables be specified on Class statement in Proc Tabulate? Yes60. Write the table definition with table structure in proc tabulate?

When do we use Tabulate Procedure: by default freq proc generates freq counts and means proc generates stats specified so the report generation is predefined by the system, to print a report as per user requirement then use tabulate procedure which is user defined table structureORTabulate procedure is user defined table construction as per the report requirement.

Proc tabulate data = libref.inputdataset out=libref.outputdtaset;Class var1 var2 var3; * Char/Num Vars;Var anavar1 anavar2 anavar3; * Num Vars;Table page-exp-var1, row-exp-var2,col-exp-var3*anavar1*(Sum Min

Max);Run;Class statement defines the variables to be considered for grouping the dataVar statement specified the anavar to be used to generate statisticsTable statement in proc tabulate defines the table structure as per user requirement

Whatever variables defined on table statement it should be available either On CLASS or VAR statement

61. What is Report Procedure? Purpose? How do you enhance each and every variable in the output result in Report Procedure?

62. Define the options on Proc Report that you know?

Page 16: New Good N easy Base Sas Interview Questions by Topic

Kelly Technologies

Flat No: 212, 2nd floor,Annapurna Block, Aditya Enclave,Ameerpet,Hyderabad-16.E-mail: [email protected]: +9140 6462 6789, +91 998 570 6789Online and Classroom Trainings for SAS, SAS BI

63. What is the purpose of Display /Analysis / Flow / Spacing = option / Split = ‘spl char’ / Headline / Headskip / Dol,Dul,Ol, Ul / summarize / rbreak after/before / break after/before / column statement / define statement / Across in Proc Report ?

64. What is Order / Across / Group usage in Proc Report?

65. What is the difference between Order and Group variable in proc report?Order Statement generates listing report with detailed rows and sorting in ascending order by default and suppressing the repetitive printing of the values

Group Statement generates summary report

66. In Proc Report give some ways by which you can define the variables to produce the summary report?

67. Give some example where PROC REPORT’s defaults are different than PROC PRINT’s defaults?

No Record Numbers in Proc Report Labels (not var names) used as headers in Proc Report REPORT needs NOWINDOWS option

68. Give some example where PROC REPORT’s defaults are same as PROC PRINT’s defaults?

Variables/Columns in position order. Rows ordered as they appear in data set.

69. Do you prefer PROC REPORT or PROC TABULATE? Why?

70. Purpose of ID / BY statement in proc Transpose? Pre-requisite for By statement in proc transpose?

71. How would you code the criteria to restrict the output to be produced?Use NoPrint Option

72. How to read raw data files?

73. Identify statements whose placement in the DATA step is critical.Data, Run statements

Page 17: New Good N easy Base Sas Interview Questions by Topic

Kelly Technologies

Flat No: 212, 2nd floor,Annapurna Block, Aditya Enclave,Ameerpet,Hyderabad-16.E-mail: [email protected]: +9140 6462 6789, +91 998 570 6789Online and Classroom Trainings for SAS, SAS BI

74. What is a method for assigning first.VAR and last.VAR to the BY group variable on unsorted data?

First. And Last. Cannot be used on Unsorted Data

75. What is the Program Data Vector (PDV)? What are its functions?76. How would you determine the number of missing or nonmissing values in

computations?

77. What is _n_?Every data step that is executed creates _N_ automatic variable. Each time the data step loops past the DATA statement, _N_ is incremented by 1. Therefore the value of _N_ represents the number of times that the DATA step iterated. Note: _N_ is added to the PDV, but it is not output.

78. SCAN vs. SUBSTR function?79. What system option determines whether the macro facility searches a specific catalog for a stored, compiled macro?80. Do you know about the SAS autoexec file? What is its significance?81. I want to make a quick backup of a data sets along with any associated indexes What procedure can I use?82. What does the statement 'format _all_;' do?83. Can a FORMAT, LABEL, DROP, KEEP, or LENGTH statements use array

References ?84. What is the one statement to set the criteria of data that can be coded in any step?

Options Statement

85. What is the effect of the OPTIONS statement ERRORS=1?86. What's the difference between VAR A1 - A4 and VAR A1 -- A4?

A1- A4 ( Named Range Lists ) - Specifies all variables from a1 to a4 inclusive. You can begin with any number and end with any number as long as you do not violate the rules for user-supplied variable names and the numbers are consecutive.

A1 -- A4 - Specifies all the variables from a1 to a4 inclusive

87. What do the SAS log messages "numeric values have been converted to character" mean? What are the implications?

Page 18: New Good N easy Base Sas Interview Questions by Topic

Kelly Technologies

Flat No: 212, 2nd floor,Annapurna Block, Aditya Enclave,Ameerpet,Hyderabad-16.E-mail: [email protected]: +9140 6462 6789, +91 998 570 6789Online and Classroom Trainings for SAS, SAS BI

88. Why is a STOP statement needed for the POINT= option on a SET statement? Because POINT= reads only the specified observations, SAS cannot detect an end-of-file condition as it would if the file were being read sequentially

89. How do you control the number of observations and/or variables read or written? FIRSTOBS and OBS / DROP or KEEP

90. Approximately what date is represented by the SAS date value of 730? 91. Does SAS 'Translate' (compile) or does it 'Interpret'? Explain.

A typical SAS program could contain DATA steps, PROC steps and macros. Macros are preprocessed.DATA steps are just in time compiled. PROC steps are interpreted in the order they appear in program.So when we submit a SAS program consisting of all these three components, the macro is compiled and executed first.If a DATA step is encountered, then it is compiled and executed. Note that the DATA step will not be executed if there is an error in the compilation. If a PROC step is encountered, it is interpreted and executed line by line

92. At Compile Time when a SAS dataset is read, what items are created?Input Buffer, PDV, Descriptor Information

93. What does the RUN statement do? When SAS editor looks at Run it starts compiling the data or proc step, if you have more than one data step or proc step or if you have a proc step Following the data step then you can avoid the usage of the run statement

94. What are some good SAS programming practices for processing very large data sets?

95. What is the different between functions and PROCs that calculate the same simple descriptive statistics?For example Functions will give an Sum / Avg / Min / Max across an observation Procedures will give an Sum / Avg / Min / Max across many Observations

Functions Summarizes across Observations Procedures summarizes across Variables

Page 19: New Good N easy Base Sas Interview Questions by Topic

Kelly Technologies

Flat No: 212, 2nd floor,Annapurna Block, Aditya Enclave,Ameerpet,Hyderabad-16.E-mail: [email protected]: +9140 6462 6789, +91 998 570 6789Online and Classroom Trainings for SAS, SAS BI

96. If you were told to create many records from one record, show how you would do this using arrays and with PROC TRANSPOSE? I would use TRANSPOSE if the variables are less use arrays if the var are more

97. What is a method for assigning first.VAR and last.VAR to the BY groupvariable on unsorted data?

98. How do you debug and test your SAS programs? First thing is look into Log for errors or warning or NOTE in somecases or use the debugger in SAS data step Or

Print PUT Statement and DEBUG option is used for dubug and test the programs

99. What other SAS features do you use for error trapping and data validation? Error Trapping – Log WindowData Validation – Proc Freq , Proc Means, Proc Tabulate etc.

100. How would you combine 3 or more tables with different structures? Sort them with common key variables and use merge statement. If the key variable names are varying then rename the variables as per requirement .

101. Describe 5 ways to do a "table lookup" in SAS. Match Merging, Format Table, Arrays, Proc Sql, Direct Access

102. What are some problems you might encounter in processing missing values? In Data steps? Arithmetic? Comparisons? Functions? Classifying data? The result of any operation with missing value will result in missing value. Most sas statistical procedures exclude observations with any missing values from an analysis

103. How would you create a data set with 1 observation and 30 variables from a data set with 30 observations and 1 variable? Proc Transpose

104. What are _numeric_ and _character_ and what do they do? Selects all numeric or character variable. It can be used in drop or keep dataset options/statements or Variable Range Lists

105. How would you create multiple observations from a single observation?

Page 20: New Good N easy Base Sas Interview Questions by Topic

Kelly Technologies

Flat No: 212, 2nd floor,Annapurna Block, Aditya Enclave,Ameerpet,Hyderabad-16.E-mail: [email protected]: +9140 6462 6789, +91 998 570 6789Online and Classroom Trainings for SAS, SAS BI

Using Double Trailing @@

106. For what purpose would you use the RETAIN statement? 107. How could you generate test data with no input data?

Using Data _Null_ and Put statement

108. What can you learn from the SAS log when debugging? It will display the execution of whole program and the logic.

109. What is the purpose of _error_? During program execution if data errors exist then sas prints a message to the log window and sets the automatic temporary variable _error_ to 1 for the Current Observation

110. How does SAS handle missing values in: assignment statements, functions, a merge, an update, sort order, formats, PROCs? Assignment Statement – treat as zero valueFunctions – ignores missing values for some statistical functions and mathematical functions or treat it as zero(sum func)Sort Order – treats missing as secord smallest followed by underscoreFormat – Ignore missing valuesReport Procedures – ignores missing values with observations and consider non missing value for calculation

111. How do you test for missing values? By using IF or WHERE conditions

NMISS option is used for missing values

112. How are numeric and character missing values represented internally? Characters as Blank and Numeric as period (.)

113. Which date functions advances a date time or date/time value by a given interval? INTNX function

114. In the flow of DATA step processing, what is the first action in a typical DATA Step?

115. What are SAS/ACCESS and SAS/CONNECT? SAS/Access only process through the databases like Oracle, SQL-server, Ms-Access etc. SAS/Connect only use Server connection

Page 21: New Good N easy Base Sas Interview Questions by Topic

Kelly Technologies

Flat No: 212, 2nd floor,Annapurna Block, Aditya Enclave,Ameerpet,Hyderabad-16.E-mail: [email protected]: +9140 6462 6789, +91 998 570 6789Online and Classroom Trainings for SAS, SAS BI

116. What is the difference between calculating the 'mean' using the mean function and PROC MEANS?

117. I want to save hard drive space. How do I write a code to delete some or all temporary files once I do not need them any more? Delete some temporary files from "Work" library:

proc datasets library=work memtype=data;delete test1 test2;*deletes datasets test1 & test2 and keeps the rest;quit;

118. What is a problem with merging two data sets that have variables with the same name but different data?119.  I am using a very huge data set in SAS for windows. How do I minimize space

requirements?1.Split huge data set into smaller data sets.2. Clean up your working space as much as possible at each step.3. Use dataset options (keep= , drop=) or statement (keep, drop) to limit to only the variables needed. 4. Use IF statement or OBS = to limit the number of observations. 5. Use WHERE= or WHERE or index to optimize the WHERE expression to limit the number of observations in a Proc Step and Data Step. 6. Use length to limit the bytes of variables.7. Use _null_ dataset name when you don't need to create a dataset. 9. Use SQL to do merge, summary, sort etc. rather than a combination of Proc Step and Data Step with temporary datasets.

120. Which data set is the controlling data set in the MERGE statement?

121. How do the IN= variables improve the capability of a MERGE?122. Given an unsorted dataset, how to read the last observation to a new data

set?

End= data set option. By creating End Of File Indicator on input dataset.For example:data work.calculus; set work.comp end=last;

Page 22: New Good N easy Base Sas Interview Questions by Topic

Kelly Technologies

Flat No: 212, 2nd floor,Annapurna Block, Aditya Enclave,Ameerpet,Hyderabad-16.E-mail: [email protected]: +9140 6462 6789, +91 998 570 6789Online and Classroom Trainings for SAS, SAS BI

If last;run;

123. Give some example where PROC REPORT’s defaults are same as PROC PRINT’s defaults?

Variables/Columns in position order (var/column statement). Rows ordered as they appear in data set (no sorting of rows)

124. Code the table's statement for a single level frequency?125. What is Enterprise Guide? What is the use of it? 126. How would you code a merge that will keep only the observations that have

matches from both data sets? (IN = dataset option on MERGE statement)

127. What are input dataset and output dataset options?128. Difference b/w sum function and using “+” operator?

SUM function returns the sum of non-missing arguments whereas “+” operator returns a missing value if any of the arguments are missing.

129. How can u create zero observation dataset? ( OBS = 0) 130. What would be the result if all the arguments in SUM function are missing?

A missing value

131. What is SAS GRAPH?132. Why is SAS considered self-documenting?

SAS is considered self documenting because during the compilation time it creates and stores all the information about the data set like the time and date of the data set creation later No. of the variables later labels all that kind of info inside the dataset and you can look at that info using proc contents procedure

133. What has been your most common programming mistake?I remember Missing semicolon and not checking log after submitting program, Not using debugging techniques are my common programming errors I made when I started learning SAS and in my initial projects.

134. Name several ways to achieve efficiency in your program. Explain trade-offs.Efficiency and performance strategies can be classified into 5different areas.·- CPU time

Page 23: New Good N easy Base Sas Interview Questions by Topic

Kelly Technologies

Flat No: 212, 2nd floor,Annapurna Block, Aditya Enclave,Ameerpet,Hyderabad-16.E-mail: [email protected]: +9140 6462 6789, +91 998 570 6789Online and Classroom Trainings for SAS, SAS BI

- Data Storage

Efficiency improving techniques:- Using KEEP and DROP statements to retain necessary variables.- Use macros for reducing the code.- Using IF-THEN/ELSE statements to process data programming.

135. What is the significance of the ‘OF’ in X = SUM (OF a1-a4,a6, a9);136. What do the INPUT and PUT Functions do?137. Give an example where SAS fails to convert character value to numeric value

automatically?Suppose value of a variable Salary begins with a dollar sign ($). When SAS tries to automatically convert the values of Salary to numeric values, the dollar sign blocks the process. The values cannot be converted to numeric values.

138. What would be the resulting numeric value (generated by automatic char to numeric conversion) of a below mentioned character value when used in arithmetic calculation? 1,735.00A missing value

139. Which SAS statement does not perform automatic conversions in comparisons?Where Statement

140. Name few SAS functions?The interviewer frequently ask this question to test which SAS functions you are going to specify and ask questions based on your answer. Be prepared with all the functions.

Define each and every function with syntax and its objective

141. What date time functions come under numeric functions?SAS stores date and time values as STANDARD NUMERIC VALUES i.e. the Number of Days Difference between the Base Sas Date Vlaue (01Jan1960) and the

Page 24: New Good N easy Base Sas Interview Questions by Topic

Kelly Technologies

Flat No: 212, 2nd floor,Annapurna Block, Aditya Enclave,Ameerpet,Hyderabad-16.E-mail: [email protected]: +9140 6462 6789, +91 998 570 6789Online and Classroom Trainings for SAS, SAS BI

Specified date. Since the years / weeks / days / qtrs difference between two date values cannot be calculated on character value we convert to numeric value and apply date time numeric functions

142. Difference between SCAN and SUBSTR function?143. What are the parameters of Scan function?

Scan (argument, n, delimiters)

argument specifies the character variable or expression to scan n specifies which word to read

delimiters are special characters that must be enclosed in single quotation marks

144. What is the length assigned to the target variable by the scan function?200 bytes by default for SCAN function, the length can be changed by specifying LENGTH statement

145. Difference between SAS Functions and Procedures?Functions expect argument value to be supplied across an observation in a SAS data set and procedure expects one variable value per observation.

For example:data average ;

set temp ;avgtemp = mean( of T1 – T24 ) ;

run ;

Here arguments of mean function are taken across an observation.proc sort ;by month ;

run ;

proc means ;by month ;var avgtemp ;

run ;

Page 25: New Good N easy Base Sas Interview Questions by Topic

Kelly Technologies

Flat No: 212, 2nd floor,Annapurna Block, Aditya Enclave,Ameerpet,Hyderabad-16.E-mail: [email protected]: +9140 6462 6789, +91 998 570 6789Online and Classroom Trainings for SAS, SAS BI

Proc means is used to calculate average temperature by month (taking one variable value across an observation).

146. What would be the result of following SAS function (given that 31 Dec, 2000 is Sunday) ?Weeks = intck (‘week’,’31 dec 2000′d,’01jan2001′d);Years = intck (‘year’,’31 dec 2000′d,’01jan2001′d);

147. How do you use the do loop if you don’t know how many times should you execute the do loop?Do Until or Do While to specify the condition and stop the loop conditionallydata work;

do i=1 to 20 until(Sum>=20000);Year+1;Sum+2000;Sum+Sum*.10;

end;run;

148. Have you ever linked SAS code? If so, describe the link and any required statements used to either process the code or the step itself?

149. What statement you code to tell SAS that it is to write to an external file? What statement do you code to write the record to the file?FILE and PUT StatementsSas Sql Interview Questions

150. Define different functions which can accomplish with proc sql151. What is The SQL Procedure Pass-Through Facility?152. Name four set operators?153. What is the COALESCE function?154. State some differences between the DATA Step and SQL?155. What is the use of Proc SQL?

Page 26: New Good N easy Base Sas Interview Questions by Topic

Kelly Technologies

Flat No: 212, 2nd floor,Annapurna Block, Aditya Enclave,Ameerpet,Hyderabad-16.E-mail: [email protected]: +9140 6462 6789, +91 998 570 6789Online and Classroom Trainings for SAS, SAS BI

SAS MACRO Interview Questions1. What is SAS Macro? Purpose of SAS Macro Prog Language or Why SAS

Macros ?SAS Macros is REUSABILITY. Create a Macro Program once and re-use it any

number of times as per user requirement.

2. What are the components of a SAS Macro?The Two components of SAS Macro is MACRO PROCESSOR and MACRO

Prog Language.Macro Processor is the one that does the work.

1. creates a macro variable and stores the value in CPU Memory2. resolve the macro variable reference by searching for the

macro variable value in CPU Memory

Page 27: New Good N easy Base Sas Interview Questions by Topic

Kelly Technologies

Flat No: 212, 2nd floor,Annapurna Block, Aditya Enclave,Ameerpet,Hyderabad-16.E-mail: [email protected]: +9140 6462 6789, +91 998 570 6789Online and Classroom Trainings for SAS, SAS BI

Macro Programming Language which communicates to the Macro Processor.

3. What is Macro Processor?4. What is Macro Trigger? In the FLOW OF MACRO Program steps the sas program is read from Input Stack to Word Scanner, the Word Scanner searches for Macro Triggers i.e. %let statement and a macro variable reference by &macvarname, if found it is directed To Macro Processor.

5. How do you create a macro variable ? They are various ways in which the macro variable can be created depending upon the requirement:

1. %let statement create a macro variable and assign the valueScope: Global Macro Variable if created outside the macro

program and Local Macro Variable if created inside the Macro Program2. Creating a macro variable during proc sql execution by storing the value

of the variable in the dataset into a macro variable. In other words creating a macro variable using PROC SQL INTO Clause.

Scope: If proc sql created outside the macro program the macro variables are global mac variables and if the proc sql created inside the macro program then it is local macro variable.3. Creating a macro variable during DATA STEP EXECUTION using

CALL SYMPUT. CALL SYMPUT or CALL SYMPUTX creates a macro variable during data step execution by storing the value of the variable in output dataset into a macro variable

Scope: By default the CALL SYMPUT creates a Global macro variable4. Passing the macro variable as PARAMETER to the macro program.

Scope: by default the parameters are created as Local mac vars5. %Global statement defines explicitly to store macro variable as Global

Macro Variable6. %Local statement defines explicitly to store macro variable as Local

Macro Variable7. Creating a macro variable in the macro program with the %do iteration

statement. In the below the index is a local macro variable created.

Page 28: New Good N easy Base Sas Interview Questions by Topic

Kelly Technologies

Flat No: 212, 2nd floor,Annapurna Block, Aditya Enclave,Ameerpet,Hyderabad-16.E-mail: [email protected]: +9140 6462 6789, +91 998 570 6789Online and Classroom Trainings for SAS, SAS BI

Syntax: %do index = startvalue %to endvalue; Sas statements;

%end;

6. Where is the macro variable value stored?Scope of a Macro Variable. The scope of a macro variable can be Global or Local macro variable.

The macro processor is going to store the macro variables and its value in the CPU MEMORY in a symbol table or

The Macro variable/s are stored in the SYMBOL TABLE of CPU MEMORY. The Symbol table can be Global or Local Symbol table depending on the scope of Macro Variable

7. What is the Scope of the Macro Variable ? How we can create macro variable?8. What do you code to create a macro program?

Create a stored compiled macro program embedded with data and proc step Statements.

Syntax: %macro macr-prgm-name(parameters);Data;Proc;

%mend macr-prgm-name;

9. What is stored compiled macro program and what is its use? Whenever the macro program (%macro macr-prgm-name) executed it creates a Stored Compiled macro program and store it into a default work library, sasmacr catalog folder with the macro program name. Generally macro is re-usability, so if the macro program is stored to a library then any user can call the stored compiled macro program and generate the output results. The stored compiled macro program checks for syntax errors while executed, if errors exist then it stops execution and prints the error messages to log window otherwise it stores the macro program as stored compiled macro program to the default work or specified library in sasmacr catalog folder.

10. How would you identify a macro variable?

Page 29: New Good N easy Base Sas Interview Questions by Topic

Kelly Technologies

Flat No: 212, 2nd floor,Annapurna Block, Aditya Enclave,Ameerpet,Hyderabad-16.E-mail: [email protected]: +9140 6462 6789, +91 998 570 6789Online and Classroom Trainings for SAS, SAS BI

A Macro variable is always referenced by & (ampersand).Syntax: &macvarreference

11. How would you define the end of a macro program?%mend statement defines the end of a macro program

12. Have you used macros? For what purpose you have used? Creating a macro depends on the reporting and data requirement and how often the macro program is reused.

General macro programs that are created and used are:- macro program for sorting- macro program for combining sas datasets- macro program to create multiple output datasets- macro program for appending- macro program for report generation based on the user selected parameter

values

13. How would you invoke a macro / execute a macro / call a macro program?A stored compiled macro program is exectuted / invoked or called using

%macro-program-name(parameters)

14. How can you create a macro variable using proc sql execution?During the proc sql execution the value of the variable on output dataset is stored

into a macro variable defined in the INTO: clause

Syntax: proc sql; Select variable into: macvar From libref.inputdataset;Quit;

15. How can you create a macro variable with in data step? Or Tell me about call symput? During the execution of data step statement the value of the variable on output

Dataset is stored into a macro variable by using CALL SYMPUT.

Page 30: New Good N easy Base Sas Interview Questions by Topic

Kelly Technologies

Flat No: 212, 2nd floor,Annapurna Block, Aditya Enclave,Ameerpet,Hyderabad-16.E-mail: [email protected]: +9140 6462 6789, +91 998 570 6789Online and Classroom Trainings for SAS, SAS BI

In other words, CALL SYMPUT creates a macro variable and stores the value of The variable on output dataset during DATA STEP EXECUTION

Syntax: CALL SYMPUT(‘Macvarname’,Variable);Data libref.outputdataset;

Set libref.inputdataset;CALL SYMPUT(‘Macvarname’,Variable);

Run;Note: The CALL SYMPUT does not remove leading and trailing blanks from the

variable value on output dataset while storing to a macro variable

16. When we can use call symputx and why?CALL SYMPUX creates a macro variable and store the value of the variable on

output dataset by removing the leading and trailing blanks.

Syntax: CALL SYMPUTX(‘macvarname’,variable);

17. If you use a SYMPUT in a DATA step, when and where can you use the macro variable?The macro variable created from SYMPUT in data step statement can be

referenced in any program or macro program

18. Can you define macro debugging system options?They are various macro debugging options for the sas programmer which are

turned off by default, this can be turned on in development while executing the code and later again turned off.

Macro Debugging Options should be specified in SYSTEM OPTIONS, i.e. in OPTIONS Statement, The various SYSTEM OPTIONS available for Macro Debugging are:

Options Mprint Mlogic Symbolgen Merror Mprintnest Mlogicnest;Options noMprint noMlogic noSymbolgen noMerror noMprintnest noMlogicnest;

Page 31: New Good N easy Base Sas Interview Questions by Topic

Kelly Technologies

Flat No: 212, 2nd floor,Annapurna Block, Aditya Enclave,Ameerpet,Hyderabad-16.E-mail: [email protected]: +9140 6462 6789, +91 998 570 6789Online and Classroom Trainings for SAS, SAS BI

* SYMBOLGEN system option - prints the value of the resolving macro variable in the sas log;

* Use Symbolgen Option in place of %Put Statement;* %PUT statement prints the values of the macro variables when defined by the user in the program but symbolgen system

option prints the value of the macr variable during macro executeion wherever the macro variable is

referenced* MLOGIC system option - prints in the sas log when the exectuion started and ended for each macro application;* MPRINT system option - prints the sas program to the sas log window;* MERROR system option - prints the error line number when any error occrus during exectuion;* MPRINTNEST - Specifies whether to display the macro nesting information in the MPRINT output in the SAS log* MLOGICNEST - Specifies whether to display the macro nesting information

in the MLOGIC output in the SAS log

Mcompilenote is not a macro debugging option:* MCOMPILENOTE=ALL - Issues a NOTE to the log window which confirms that the compilation of the macro was completed.

%macro macprgmname;%mend;

19. What is the difference between %PUT and SYMBOLGEN?%PUT statement prints the value of the macro variables referenced onto log

WindowSYMBOLGEN system options prints the values of the macro variable referenced

during the execution of the macro program onto log window

20. How can you print the values of the macro variables onto log window?%put _user_ %put _global_%put _local_%put _automatic_%put _all_

Options Symbolgen

Page 32: New Good N easy Base Sas Interview Questions by Topic

Kelly Technologies

Flat No: 212, 2nd floor,Annapurna Block, Aditya Enclave,Ameerpet,Hyderabad-16.E-mail: [email protected]: +9140 6462 6789, +91 998 570 6789Online and Classroom Trainings for SAS, SAS BI

21. Can you execute a macro within a macro? Describe.Yes. This is called as NESTED MACRO PROGRAMS.

22. Can you execute macro within another macro? If so, how would SAS know where the current macro ended and the new one began?In nested macro program to know where the current macro ended and the new one began, use SYSTEM OPTION MLOGIC, which displays onto log window when the macro program started execution and when it is ended.

23. How are parameters passed to a macro? OR Tell me more about the parameters in macro?They are are three different ways in which the macro variables can be passed as parameters to the stored compiled macro program.

1. Positional Parameters %macro sorting(libref, dsname, byvars)2. Key Word Parameters %macro sorting(libref=,dsname=,byvars=)3. Mixed Parameters %macro sorting(libref,dsname=,byvars=)

24. How would you code a macro statement to produce information on the SAS log?Options Mprint

25. What is the maximum length of the macro variable?Macro variable values have a maximum length of 65,534 characters

26. Print few Automatic variables of a macro program?System defined automatic macro variables gets created during the invocation of the sas software:&sysdaste

&sysdate9&systime&sysuserid&syslast

27. What system options would you use to help debug a macro?

Page 33: New Good N easy Base Sas Interview Questions by Topic

Kelly Technologies

Flat No: 212, 2nd floor,Annapurna Block, Aditya Enclave,Ameerpet,Hyderabad-16.E-mail: [email protected]: +9140 6462 6789, +91 998 570 6789Online and Classroom Trainings for SAS, SAS BI

MERROR: SAS will issue warning if we invoke a macro that SAS didn’t find. Presents Warning Messages when there are misspellings or when an undefined macro is called.MLOGIC: SAS prints details about the execution of the macros in the log.MPRINT: Displays SAS statements generated by macro execution are traced on the SAS Log for debugging purposes.SYMBOLGEN: SAS prints the value of macro variables in log and also displays text from expanding macro variables to the SAS Log.MEMRPT: Specifies that memory usage statistics be displayed on the SAS Log.SERROR: SAS will issue warning if we use a macro variable that SAS can’t find.

28. What are SYMGET and SYMPUT?SYMPUT creates a macro variable during data step execution by storing the value of the variable on output dataset to a macro variable

CALL SYMPUT(‘macvarname’,variable);

SYMGET searches for the macro variable specified in Global Symbol Table by default and if it is found then it fetches the value from symbol table and assign to the variable on output dataset

Newvar = SYMGET(macvarname)

29. What is auto call macro and how to create a auto call macro? What is the use of it? How to use it in SAS with macros?

SAS Enables the user to call macros that have been stored as SAS programs.The auto call macro facility allows users to access the same macro code from multiple SAS programs. Rather than having the same macro code for in each program where the code is required, with an autocall macro, the code is in one location. This permits faster updates and better consistency across all the programs.Macro set-up:The fist step is to set-up a program that contains a macro, desired to be used in multiple programs. Although the program may contain other macros and/or open code, it is advised to include only one macro.

Set MAUTOSOURSE and SASAUTOS:Before one can use the autocall macro within a SAS program, The MAUTOSOURSE option must be set open and the SASAUTOS option should be assigned. The MAUTOSOURSE option indicates to SAS that the autocall facility is to be activated. The SASAUTOS option tells SAS where to look for the macros.

Page 34: New Good N easy Base Sas Interview Questions by Topic

Kelly Technologies

Flat No: 212, 2nd floor,Annapurna Block, Aditya Enclave,Ameerpet,Hyderabad-16.E-mail: [email protected]: +9140 6462 6789, +91 998 570 6789Online and Classroom Trainings for SAS, SAS BI

For ex: sasauto=’g:\busmeas\internal\macro\’;

30. Mention the macro functions?%symexist%symlocal%symglobl%susfunc(sasfunc,format)%str

31. What is %sysfunc ?%SYSFUNC function executes the sas functions and also prints the formatted values

32. How to execute a macro program conditionally inside the data step statement?Data libref.output;;

Set lirbef.input;If condition then execute a macro program;If condition then call execute(‘%macrprgmname(parameters)’);

Run;

CALL EXECUTE executes a stored compiled macro program conditionally inside the data step statement

33. Name macro variable attribute function?The macro variable attribute functions returns when the macro variable exists, or it is global or local macro variable:%symexist%symglobl%symlocal

All the macro attribute function returns the value 0 or 10 – does not exist, 1 - exists

34. Tell me about %include and %eval?%include statement call an external sas program into an existing program by just referring with a physical path of the sas program instead of copying the total file

Page 35: New Good N easy Base Sas Interview Questions by Topic

Kelly Technologies

Flat No: 212, 2nd floor,Annapurna Block, Aditya Enclave,Ameerpet,Hyderabad-16.E-mail: [email protected]: +9140 6462 6789, +91 998 570 6789Online and Classroom Trainings for SAS, SAS BI

%eval is going to evaluate an mathematical expression while storing to %let statement

%let a = %eval(3+7);

35. What is the difference between %LOCAL and %GLOBAL?%global statement is given to define the macro variable specified as global macro variable explicitly

%lcoal statement is given to define the macro variable specified as local macro variable explicitly. If the same macro variable name is defined locally and globally it is better to specify %local macvarname inside the macro program to store in local symbol table

36. Give example of macro quoting functions?%str - semicolon%nrstr – while assigning the value to the macro variable it does not resolve the macro variable references%let a = %nrstr(Kelly&tec);

37. What is a sas catalog?Sas catalog stores in sasmacr catalog folder stores all the stored compiled macro programs

38. How to print the directory and list of the entire macro program/s onto log window?Use CATALOG PROCEDURE to print the directory and the date created and modified each and every stored compiled macro program

39. How to copy the stored compiled macro program code to log window?%copy macrprogname / source;

Sas Clinical Interview Questions:http://saskingdom.blogspot.in/2012/02/sas-clinical-questions-with-answers.html