Interview Questions.

Top 100+ Base Sas Interview Questions And Answers


Top 100+ Base Sas Interview Questions And Answers

Question 1. What Are The Three Types Of Join?

Answer :

The 3 styles of be part of are internal join, left be part of and proper be a part of. The inner be a part of choice takes the matching values from both the tables with the aid of the ON choice. The left be part of selects all the variables from the primary desk and joins 2d table to it. The proper be part of selects all of the variables of desk b first and join the table a to it.

Question 2. Have You Ever Used Proc Sql For Data Stigmatization?

Answer :

Yes I have used it for summarization at instances…For e.G if I need to calculate the max value of BP for patients a hundred and one 102 and 103 then I use the max (bpd) feature to get the most fee and use institution through assertion to institution the sufferers for this reason.

OLAP Interview Questions
Question 3. Tell Me About Your Sql Experience?

Answer :

I actually have used the SAS/ACCESS SQL skip thru facility for reference to outside databases and uploading tables from them and additionally Microsoft get right of entry to and excel files.Besides this, lot of instances I have used PROC SQL for joining tables.

Question four. Once You Have Had The Data Read Into Sas Data Sets Are You More Of A Data Step Programmer Or A Proc Sql Programmer?

Answer :

It relies upon on what types of analysis datasets are required for growing tables however I am greater of a information step programmer because it gives me extra flexibility. For e.G growing a change from baseline information set for blood strain occasionally I should preserve sure values …use arrays ….Or use the first. -and last. Variables.

OLAP Tutorial
Question five. What Types Of Programming Tasks Do You Use Proc Sql For Versus The Data Step?

Answer :

Proc SQL is very convenient for performing table joins as compared to a records step merge as it does now not require the key columns to be sorted previous to join. A statistics step is extra appropriate for sequential commentary-by means of-statement processing.PROC SQL can shop a great deal of time if u need to filter the variables while deciding on or u can alter them …follow layout….Creating new variables , macro variables…as well as sub placing the information.PROC SQL offers brilliant flexibility for joining tables.

SAS Programming Interview Questions
Question 6. Have U Ever Used Proc Sql To Read In A Raw Data File?

Answer :

No. I don’t think it may be used.

Question 7. How Do You Merge Data In Proc Sql?

Answer :

The 3 styles of be part of are internal be a part of, left join and proper join. The inner be part of alternative takes the matching values from each the tables by means of the ON alternative. The left join selects all the variables from the primary table and joins 2d table to it. The proper be a part of selects all of the variables of table b first and be a part of the desk a to it.












SAS Programming Tutorial Clinical SAS Interview Questions
Question eight. Why And When Do You Use Proc Sql?

Answer :

Proc SQL may be very handy for acting table joins as compared to a facts step merge as it does now not require the important thing columns to be looked after prior to sign up for. A data step is greater suitable for sequential commentary-with the aid of-commentary processing.

PROC SQL can save a extremely good deal of time if u need to filter out the variables even as deciding on or we can alter them, follow format and creating new variables, macro variables. As well as subsetting the facts. PROC SQL offers excellent flexibility for becoming a member of tables.

Question 9. Difference Between Proc Means & Proc Summary?

Answer :

Proc Summary defaults to NOPRINT Proc Means defaults to PRINT
If you pass over the VAR announcement, then PROC SUMMARY produces a easy count of observations, while PROC MEANS tries to analyze all the numeric variables that are not indexed in the other statements
If you specify information on the PROC SUMMARY declaration and the VAR announcement is disregarded, then PROC SUMMARY stops processing and an errors message is written to the SAS log.
If you pass over the VAR declaration, then PROC MEANS analyzes all numeric variables that aren't indexed inside the different statements. When all variables are person variables, PROC MEANS produces a easy be counted of observations.
SQL Server Analysis Services (SSAS) Interview Questions
Question 10. How Will You Write A Code To Create A Sas Data Set With No Data In It/ Or How To Validate A Data Set Without Actual Creating It?

Answer :

2) Creating a information set by way of using the like clause.
 Ex: proc sq.;
create desk latha.Emp like oracle.Emp;
In this the like clause triggers the existing table structure to be copied to the new desk. The usage of this approach 
result in the advent of an empty table.
Three)  information test;
           set _null_;
four) data test;

Question 11. Do You Use Proc Report Or Proc Tabulate? Which Do You Prefer?

Answer :

I prefer Proc report as it is pretty customizable and flexible where I can outline each column in whatever way I  want to and even employ SAS functions, good judgment processing, and task statements and create new. 

Variables for report making use of the compute block of proc document. I referred proc file due to the fact it is greater green device than tabulate due to the fact with record we can do manner frequency and tabulate additionally.

SAS DI Interview Questions
Question 12. How Will You Read An Input File Into Sas?

Answer :

Use the statements INFILE to point to the file reference(need to be defined using Filename) / to the record route. Use INPUT declaration to study the information into the sas dataset.

OLAP Interview Questions
Question thirteen. How Would You Remove A Format That Has Been Permanently Associated With A Variable?

Answer :

we are able to cast off the layout by using the use of proc datasets:

Proc datasets;

alter <data set name>;

layout <variable name>(which variable format needs to 



give up;

Question 14. How To Display Duplicate Observations In A Data Using Base Sas?

Answer :

There are  approaches to display duplicate observations:

In facts step, the usage of first.Var and last.Var
Using proc kind with option dupout alternative.
Question 15. In The Flow Of Data Step Processing, What Is The First Action In A Typical Data Step?

Answer :

1)Compilation Phase:

When you submit a DATA step, it reads the input statements it creates an input buffer and brings the variables and observations. It is a logical memory place and pdv brings the observations at a time from enter buffer 

and exams the errors. PDV consists of 2 automated variables _n_ & _error_, those assessments the errors in observations.

_n_: indicates the no of obs.

_error_: 1 if mistakes occured

             zero if no errors

After that it assigns the records values to suitable variable and builds a sas dataset.

Advanced SAS Interview Questions
Question 16. Does Sas ?Translate? (bring together) Or Does It ?Interpret?

Answer :

A typical SAS program may want to comprise 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 software. So when we submit a SAS program which includes these types of three additives, the macro is compiled and done first. If a DATA step is encountered, then it's far compiled and accomplished. Note that the DATA step will not be completed if there may be an errors in the compilation. If a PROC step is encountered, it is interpreted and performed line via line. However i'm now not positive on this PROC step conduct.

Question 17. At Compile Time When A Sas Data Set Is Read, What Items Are Created?

Answer :

Only PDV is generated at compilation time, whereas the automatic variables _N_ , _ERROR_ are generated at execution time most effective.

SAS Macro Interview Questions
Question 18. How Do U Validate Sas Program?

Answer :

When a sas code is submitted, SAS performs syntactical exams before executing this system/ code. In that case, one of the ways can be - at the start of the code, write OPTIONS OBS=0 similarly to different options and then RUN it. 

This manner records will now not be processed and the log suggests errors messages/ warnings, if any. 

If you are executing the SAS code on PC SAS, the highlighted colorings itself shows the syntactical errors, if any.

SAS Programming Interview Questions
Question 19. Name And Describe Three Sas Functions That You Have Used, If Any?

Answer :

Compress - sas function that's used to eliminate areas in string value and concatenate  values Without areas.
Input is any other function of sas, it's miles one in every of conversion characteristic in sas. It converts numeric into char.
Put is another conversion feature in sas. It converts char to numeric.
SAS functions can be used to convert facts and control character variable values.
Extraordinary kinds of capabilities:

TRIM : Removing the trailing blanks from character expressions. 


SUBSTR: substr extracts the substring from a controversy

               syntax=substr(argument, function<,n>)

Abs: Returns the absolute of the argument


The most commonplace capabilities that would be used are-

Conversion capabilities - Input / Put / int / ceil / floor

Character capabilities - Scan / substr / index / Left / trim / compress / cat / catx / upcase,lowcase

Arithmetic capabilities - Sum / abs /

Attribute data functions – Attrn / duration

Dataset – open / close / exist

Directory  - dexist / dopen / dclose / dcreate / dinfo

File functions – fexist / fopen/ filename / fileref

SQL capabilities – coalesce / remember / sum/ suggest

Date features – date / these days / datdif / datepart / datetime / intck / mdy

Array functions – dim

Question 20. When Looking For Data Contained In A Character String Of a hundred and fifty Bytes, Which Function Is The Best To Locate That Data: Scan, Index, Or Index C?

Answer :

INDEX: Searches a individual expression for a string of characters, and returns the location of the string's first person for the primary incidence of the string.

INDEX (source, excerpt)

it returns the position in which the 2nd field is inside the source


     str1 = 'Hi i'm first-class right here. How are u there ? .....';

     str2 = index(str1,'how'); --> str2 = 20

SCAN is to get a substring upto stated man or woman. Scan feature the high-quality for locating the specific phrase specified in a argument,scan characteristic default length is 200bytes.

Facts k;

r='ganesh kumar';


proc print;


end result:  kumar

INDEXC to locate handiest for noted one or more single individual

        INDEXC(individual-price, 'char1','char2','char3', ..)

FIND: Searches for a specific substring of characters inside a individual string

 FIND(string, substring<,modifiers><,startups>)

it returns the placement the substring is in

FINDC: To locate a person that appears or does not seem within a string. Used to look for someone in a list of individual values

INDEXW: Searches for the substring as a phrase that follows a space in the supplied sentence

eg;string1= "there is a the here" ;


result: 12 (the word "the")

Question 21. If You Have A Data Set That Contains one hundred Variables, But You Need Only Five Of Those, What Is The Code To Force Sas To Use Only That Variable?

Answer :

Use KEEP alternative on a dataset to most effective select few variables from 100 variables. We can use KEEP choice either on set statement or statistics step assertion. If we use on SET assertion then best the five variables are created on pdv and simplest these variables are sent to the output dataset. If we use KEEP option on records step announcement then all the variables are copied into pdv and after any manipulation most effective the chosen variables on information step statement are processed and sent to output dataset.

Data abc;

  set xyz (preserve= ab cd ef gh);


information abc(keep= ab cd ef gh ij);

  set xyz;



Question 22. What Is The Purpose Of The Trailing And How Would You Use Them?

Answer :

If the facts is continuosly in facts set SAS could examine the first phrases most effective from every line inside the `datelines' block and it will forget about the rest of the line. If we use Trailing @@'it will examine completly.And another type of trailing is the usage of unmarried @ that is a line keep specifier.

Trailing @ is used to hold the document in enter buffer to execute every other enter statement on the equal datelines.
Trailing @@ is used to keep the file in enter buffer to execute identical enter statement on identical datelines intel eof record.
The trailing @ or more technically, line maintain specifiers are used to hold the pointer within the equal report for more than one iterations. 
The two tyoes of line maintain specifiers are single trailing(@) and double trailing(@@).
The unmarried trailing keep the file until it encounters both every other enter assertion or quit of the data step.  
They are used for the statistics including 

001F38   H

002 F 40 G

To examine those values to the facts step

Data instance:

  input @10 type $ @;

  if kind='H' then

    enter @1 identity 3. @four gender $1. @five age2.;

  else if kind='G' then

    input @1 id3. @five gender $1. @7 age 2.;

  give up;

playing cards;

001F38   H

002 F 40 G



The double trailing holds the until the quit of the record.

Data example2:

  input id age @@;

playing cards;

001 23 002 forty three 003 sixty five 004 32 half fifty four



Question 23. What Is The Significance Of The ‘of’ In X=sum (of A1-a4, A6, A9);?

Answer :

It is use to inform sas to keep in mind a hard and fast of values to be processed. In the above example, SUM(OF a1-a4,a6,a9) resolves to SUM(A1,A2,A3,A4,A6,A9).

If we dont use 'OF' then it would be dealt with as a minus sign.. A1(Minus)-A4 and that isn't what we are attempting to perform.

Question 24. How Do You Test For Missing Values?

Answer :

NMISS OPTION is used for missing values.

Clinical SAS Interview Questions
Question 25. How Would You Create Multiple Observations From A Single Observation?

Answer :

line pointer is used for a couple of traces consistent with commentary

  @@ is used for a couple of observations consistent with line

Question 26. What Are Some Good Sas Programming Practices For Processing Very Large Data Sets?

Answer :

Arrays is used for processing for big facts set.

Question 27. Why Is Sas Considered Self-documenting?

Answer :

When data set is created sas create descriptor portion and information element .Meaning sas shops the records like variable name ,duration,type etc.

SQL Server Analysis Services (SSAS) Interview Questions
Question 28. How Does Sas Handle Missing Values In: Assignment Statements, Functions, A Merge, An Update, Sort Order, Formats, Procs?

Answer :

When you test for ordinary lacking numeric values, you could use code that is similar to the subsequent: 

if numvar=. Then do;

If your data consists of unique lacking values, you may test for either an everyday or unique missing value with a announcement that is much like the subsequent: 

if numvar<=.Z then do;

To take a look at for a lacking character cost, you could use a assertion this is just like the following: 

if charvar=' ' then do;

The MISSING characteristic permits you to test for both a man or woman or numeric lacking cost, as in: 

if lacking(var) then do;