25
Search Tech Interviews SAS interview questions By admin | October 12, 2004 1. What SAS statements would you code to read an external raw data file to a DATA step? 2. How do you read in the variables that you need? 3. Are you familiar with special input delimiters? How are they used? 4. If reading a variable length file with fixed input, how would you prevent SAS from reading the next record if the last variable didn’t have a value? 5. What is the difference between an informat and a format? Name three informats or formats. 6. Name and describe three SAS functions that you have used, if any? 7. How would you code the criteria to restrict the output to be produced? 8. What is the purpose of the trailing @? The @@? How would you use them? 9. Under what circumstances would you code a SELECT construct instead of IF statements? 10. What statement do 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? 11. If reading an external file to produce an external file, what is the shortcut to write that record without coding every single variable on the record? 12. If you’re not wanting any SAS output from a data step, how would you code the data statement to prevent SAS from producing a set? 13. What is the one statement to set the criteria of data that can be coded in any step? 14. 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. 15. How would you include common or reuse code to be processed along with your statements? 16. When looking for data contained in a character string of 150 bytes, which function is the best to locate that data: scan, index, or indexc? 17. If you have a data set that contains 100 variables, but you need only five of those, what is the code to force SAS to use only those variable? 18. Code a PROC SORT on a data set containing State, District and County as the primary variables, along with several numeric variables. 19. How would you delete duplicate observations? 20. How would you delete observations with duplicate keys? 21. How would you code a merge that will keep only the observations that have matches from both sets. 22. How would you code a merge that will write the matches of both to one data set, the non-matches from the left-most data set to a second data set, and the non-matches of the right-most data set to a third data set. 23. What is the Program Data Vector (PDV)? What are its functions? S earch

SAS Interview Questions

Embed Size (px)

Citation preview

Page 1: SAS Interview Questions

Search Tech Interviews

SAS interview questions

By admin | October 12, 2004

1. What SAS statements would you code to read an external raw data file to a DATA step?

2. How do you read in the variables that you need?

3. Are you familiar with special input delimiters? How are they used?

4. If reading a variable length file with fixed input, how would you prevent SAS from reading the

next record if the last variable didn’t have a value?

5. What is the difference between an informat and a format? Name three informats or formats.

6. Name and describe three SAS functions that you have used, if any?

7. How would you code the criteria to restrict the output to be produced?

8. What is the purpose of the trailing @? The @@? How would you use them?

9. Under what circumstances would you code a SELECT construct instead of IF statements?

10. What statement do 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?

11. If reading an external file to produce an external file, what is the shortcut to write that

record without coding every single variable on the record?

12. If you’re not wanting any SAS output from a data step, how would you code the data

statement to prevent SAS from producing a set?

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

14. 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.

15. How would you include common or reuse code to be processed along with your statements?

16. When looking for data contained in a character string of 150 bytes, which function is the

best to locate that data: scan, index, or indexc?

17. If you have a data set that contains 100 variables, but you need only five of those, what is

the code to force SAS to use only those variable?

18. Code a PROC SORT on a data set containing State, District and County as the primary

variables, along with several numeric variables.

19. How would you delete duplicate observations?

20. How would you delete observations with duplicate keys?

21. How would you code a merge that will keep only the observations that have matches from

both sets.

22. How would you code a merge that will write the matches of both to one data set, the non-

matches from the left-most data set to a second data set, and the non-matches of the right-

most data set to a third data set.

23. What is the Program Data Vector (PDV)? What are its functions?

24. Does SAS ‘Translate’ (compile) or does it ‘Interpret’? Explain.

25. At compile time when a SAS data set is read, what items are created?

26. Name statements that are recognized at compile time only?

27. Identify statements whose placement in the DATA step is critical.

28. Name statements that function at both compile and execution time.

Search

Page 2: SAS Interview Questions

29. Name statements that are execution only.

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

31. What is _n_?

www.accenture.com

42 COMMENTS ON SAS INTERVIEW QUESTIONS

1. Ruksana

Posted 4/17/2005 at 2:33 pm | Permalink

hi there,

i am a student learning SAS. i need answer for SAS questions which are listed on your site.

plz forward me the answers. thanks in advance.

Ruksana

2. srijana

Posted 8/21/2006 at 12:13 am | Permalink

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

3. Ravi Awari

Posted 10/24/2006 at 8:07 am | Permalink

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

Ans) SET

Page 3: SAS Interview Questions

4. Vinod Swarna

Posted 11/8/2006 at 10:07 pm | Permalink

What SAS statements would you code to read an external raw data file to a DATA step?

Ans:

Data XXX;

infile ‘yyy’;

input …..;

run;

How do you read in the variables that you need?

Ans: drop and keep.

Are you familiar with special input delimiters? How are they used?

Ans: DSD dlm missover pad.

If reading a variable length file with fixed input, how would you prevent SAS from reading

the next record if the last variable didn’t have a value?

Ans: Missover

What is the difference between an informat and a format? Name three informats or formats.

Ans: informat to read the date. Format to write the data. Informats: comma. dollar. date.

Formats can be same as informats

Name and describe three SAS functions that you have used, if any?

mean()

date()

today()

How would you code the criteria to restrict the output to be produced?

Ans: noprint

What is the purpose of the trailing @? The @@? How would you use them?

Ans: @ hold the value past the data step.

@@ hold the value till a input statement or end of the line

Under what circumstances would you code a SELECT construct instead of IF statements?

Ans: if there are many mutually exclusive conditions

What statement do 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?

Ans: data _null_

set xxx;

file ‘YYY’;

put vv ii nn oo dd;

run;

If reading an external file to produce an external file, what is the shortcut to write that record

without coding every single variable on the record?

If you’re not wanting any SAS output from a data step, how would you code the data

statement to prevent SAS from producing a set?

Page 4: SAS Interview Questions

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

Ans: set

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.

How would you include common or reuse code to be processed along with your statements?

When looking for data contained in a character string of 150 bytes, which function is the best

to locate that data: scan, index, or indexc?

If you have a data set that contains 100 variables, but you need only five of those, what is the

code to force SAS to use only those variable?

Code a PROC SORT on a data set containing State, District and County as the primary

variables, along with several numeric variables.

How would you delete duplicate observations?

How would you delete observations with duplicate keys?

How would you code a merge that will keep only the observations that have matches from

both sets.

Ans: data xxx

merge yyy(in = inxxx) zzz (in = inzzz)

by aaa;

if inxxx = 1 and inyyy = 1;

run;

How would you code a merge that will write the matches of both to one data set, the non-

matches from the left-most data set to a second data set, and the non-matches of the right-

most data set to a third data set.

What is the Program Data Vector (PDV)? What are its functions?

Ans: To store the current obs;

Does SAS ‘Translate’ (compile) or does it ‘Interpret’?

Explain.

Ans: compile.

At compile time when a SAS data set is read, what items are created?

Ans: Descriptor portion of the data set, PDV.

Name statements that are recognized at compile time only?

Ans: put

Identify statements whose placement in the DATA step is critical.

Ans: Data, Run;

Name statements that function at both compile and execution time.

Ans:input

Name statements that are execution only.

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

Ans: set the variables to missing.

What is _n_?

Ans: SAS variable to count the no of obs read.

5. Mohan

Page 5: SAS Interview Questions

Posted 11/22/2006 at 11:12 am | Permalink

If you have a data set that contains 100 variables, but you need only five of those, what is the

code to force SAS to use only those variable?

Ans: use the data step option OBS=5

Code a PROC SORT on a data set containing State, District and County as the primary

variables, along with several numeric variables.

Ans: PROC SORT

data= out= ;

BY Country State District;

RUN;

How would you delete duplicate observations?

Ans: use PROC SORT with the option NODUP

How would you delete observations with duplicate keys?

Ans: use PROC SORT with the option NODUPKEY

6. Mohan

Posted 11/22/2006 at 11:15 am | Permalink

If you have a data set that contains 100 variables, but you need only five of those, what is the

code to force SAS to use only those variable?

Ans: Sorry, my apologies for the above answer for this question. The correct answer is

use KEEP= option in the SET statement of the DATA step

7. thiyagarajan

Posted 12/20/2006 at 8:38 am | Permalink

Hi All,

1)Can you please tell me the list of compile time statements?

2)I have 100 observations from that i want to create 5 datasets like a1,a2,a3,a4,a5.Each data

set should contain 20 observation each.For ex.a1 would contain 1 to 20 obs and a2 would

contain 21-40 like that…

waiting for your comments

Page 6: SAS Interview Questions

8. Kishore Kumar.K

Posted 12/26/2006 at 12:40 am | Permalink

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

Ans:- Options

9. srinivas.MP

Posted 1/2/2007 at 10:07 am | Permalink

2)I have 100 observations from that i want to create 5 datasets like a1,a2,a3,a4,a5.Each data

set should contain 20 observation each.For ex.a1 would contain 1 to 20 obs and a2 would

contain 21-40 like that…

data a1 a2 a3 a4 a5;

set ;

if obs>=1 and =21 and =41 and =61 and

10. kavitha

Posted 1/18/2007 at 11:21 am | Permalink

hi

is the following code right for following question?

How would you code a merge that will write the matches of both to one data set, the non-

matches from the left-most data set to a second data set, and the non-matches of the right-

most data set to a third data set.

data one two three;

maerge a (in=ina) an b=(inb)

by xx;

if ina=1 and inb=1 then proc print data=one;

if ina=1 and inb=0 then proc print data=two;

Page 7: SAS Interview Questions

if ina=0 and inb=1 then proc print data = three;

run;

11. kavitha

Posted 1/18/2007 at 11:31 am | Permalink

I have 100 observations from that i want to create 5 datasets like a1,a2,a3,a4,a5.Each data

set should contain 20 observation each.For ex.a1 would contain 1 to 20 obs and a2 would

contain 21-40 like that…

let us say x is the data set that had all the 199 observations…

data a1 a2 a3 a4 a5;

set x;

if firstobs=1 and obs=20 then proc print data =a1;

if firstobs=21 and obs=40 then proc print data =a2;

if firstobs=41 and obs=60 then proc print data =a3;

if firstobs=61 and obs=80 then proc print data =a4;

if firstobs=81 and obs=100 then proc print data =a5;

run;

if you do not want the output in log file you do not have to use proc print

12. kavitha

Posted 1/18/2007 at 11:38 am | Permalink

At compile time when a SAS data set is read, what items are created?

1. input buffer

2. Program Data Vector (PDV)

3. Descriptor Information

13. kavitha

Posted 1/18/2007 at 11:46 am | Permalink

Page 8: SAS Interview Questions

When looking for data contained in a character string of 150 bytes, which function is the best

to locate that data: scan, index, or indexc?

ans: Index will give you the position

14. kavitha

Posted 1/19/2007 at 11:51 am | Permalink

can anyone please tell me if there is a sas user group or discussion forum near fairfax, va

15. Kishore Kumar.Kandikatla

Posted 3/25/2007 at 2:14 pm | Permalink

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

Ans:- Options

16. Kishore Kumar.Kandikatla

Posted 3/25/2007 at 2:18 pm | Permalink

How do you read in the variables that you need?

Using input statement.

17. Arun Mathura.G said,

Posted 4/3/2007 at 6:48 am | Permalink

Page 9: SAS Interview Questions

I have 100 observations from that i want to create 5 datasets like a1,a2,a3,a4,a5.Each data

set should contain 20 observation each.For ex.a1 would contain 1 to 20 obs and a2 would

contain 21-40 like that…

Answer:

data a1 a2 a3 a4 a5;

set x;

if _N_ >=1 and _N_ =21 and _N_ =41 and _N_ =61 and _N_ =81 and _N_

18. hi

Posted 4/4/2007 at 1:04 am | Permalink

data a1 a2 a3;

set x;

if _n_ >=1 and _n_ =21 and _n_ =41 and _n_

19. SIVA

Posted 4/10/2007 at 7:08 am | Permalink

data a1 a2 a3 a4 a5;

set x;

select;

when (_n_ le 20) output a1;

when (20

20. siva

Posted 4/10/2007 at 7:13 am | Permalink

At compile time when a SAS data set is read, what items are created?

Page 10: SAS Interview Questions

While reading a SAS data set the input buffer will not be created. It will be created only when

the external data is read. So when a sas data set is read

PDV and the descriptor portion will only be created.

21. rao

Posted 4/17/2007 at 9:49 pm | Permalink

1) what is difference between SASV8.0 and SASV9.0?

2) u r creating Macro variable where we have to stored it?

3) what is difference between SAS debugging and Macro debugging?

4)what is the feature of SET statements?

5)what is the feature of merge statements?

22. Dharsha

Posted 5/1/2007 at 8:51 am | Permalink

How would you code a merge that will keep only the observations that have matches from

both sets.

Ans)

suppose their are two files difined. assume A & B,

based on key (ID) u need only matching form both the

datasets to be in another

Data infilea;

infile infilea;

input @1 id $char10.

@11 datafiled $char100.;

Proc Sort by id;

Data infileb;

infile infileb;

input @1 id $char10.

@11 datafiled $char100.;

Proc Sort by id;

Data_null_

Merger infilea(in=a) infileb (in=b) by id;

If A=B then

File Outfile;

Page 11: SAS Interview Questions

Put @1 id Char10;

@11 Datafield $char100.

End;

23. Kiran

Posted 5/2/2007 at 5:42 am | Permalink

How would you code a merge that will write the matches of both to one data set, the non-

matches from the left-most data set to a second data set, and the non-matches of the right-

most data set to a third data set.

data one two three;

maerge a (in=ina) an b=(inb)

by xx;

if ina=1 and inb=1 then output one;

if ina=1 and inb=0 then output two;

if ina=0 and inb=1 then output three;

run;

24. Montacer

Posted 5/3/2007 at 7:09 am | Permalink

I would like to estimate a Tobit model on panel data. PROC QLIM is supposed to be the

appropriate procedure. But did not find any details on how to tell PROC QLIM that I am using

panel data. Could you mind helping me please?

25. sannidhi

Posted 5/14/2007 at 9:04 pm | Permalink

hi

%let A= 3

Page 12: SAS Interview Questions

%let B= 4

%let C= &A + &B

%let C= &C

What is the value of %Put statement?

Please give me the answer.

26. ravi

Posted 5/21/2007 at 11:44 am | Permalink

hi

%let A= 3

%let B= 4

%let C= &A + &B

%let C= &C

What is the value of %Put statement?

Please give me the answer.

c=3+4

27. Paul

Posted 5/25/2007 at 4:50 pm | Permalink

Also firstobs and obs are dataset control options. Not execution time statements. This code

will never work.

A more feasible answer is to do this:

%*sets up a bogus datasource;

data x;

do i=1 to 100;

xx=’Your Data’;

end;

run;

%*accomplishes the task;

data a1 a2 a3 a4 a5;

set x;

cnt+1; put cnt=;

if 0kavitha said,

I have 100 observations from that i want to create 5 datasets like a1,a2,a3,a4,a5.Each data

Page 13: SAS Interview Questions

set should contain 20 observation each.For ex.a1 would contain 1 to 20 obs and a2 would

contain 21-40 like that…

let us say x is the data set that had all the 199 observations…

data a1 a2 a3 a4 a5;

set x;

if firstobs=1 and obs=20 then proc print data =a1;

if firstobs=21 and obs=40 then proc print data =a2;

if firstobs=41 and obs=60 then proc print data =a3;

if firstobs=61 and obs=80 then proc print data =a4;

if firstobs=81 and obs=100 then proc print data =a5;

run;

if you do not want the output in log file you do not have to use proc print

28. Paul

Posted 5/25/2007 at 4:51 pm | Permalink

%*accomplishes the task;

data a1 a2 a3 a4 a5;

set x;

cnt+1; put cnt=;

if 0

29. bharath

Posted 7/16/2007 at 12:57 am | Permalink

hi,

these is bharath,iam learning sas will anyone give me the answers for these quetions .plz

forward me

1.name statments that functions at both compile & execution time ?

2.name statments that are execution only ?

3.what is the difference between var A1-A4 &varA1–A4?

4.wat is the order of evaluation of the comparison operators : + - */** () ?

5.wat is the significance of the ‘OF’ in x= sum (OF a1-a4,a6,a9); ?

Page 14: SAS Interview Questions

30. kishore kumar kandikatla

Posted 7/28/2007 at 2:21 pm | Permalink

Hi rao here are my comments:

1) what is difference between SASV8.0 and SASV9.0?

ans:- u can take this as one: SASv9 (x)…more improved version from sas with respect to BI

tools and with many advanced features.

SASv8.0:- limited features not that much concentrated on BI tools.

2) u r creating Macro variable where we have to stored it?

ans: it depends on you, if u want to make them as reusable components u can save them in

one pertucular location and u can call them by using %include.

3) what is difference between SAS debugging and Macro debugging?

ANS: debugging is debuggin. no idea.

4)what is the feature of SET statements?

ans: you can apply transformations and u can even load the data.

one importance: its a technique to improve the efficiency of sas programs.

5)what is the feature of merge statements?

One simple answer is u can perform all types of joins.

31. nvv

Posted 8/14/2007 at 7:18 am | Permalink

How would you code a merge that will write the matches of both to one data set, the non-

matches from the left-most data set to a second data set, and the non-matches of the right-

most data set to a third data set.

THIS NOT WORKING GUYS… PLZ CHECK IT

filename x ‘C:\Documents and Settings\vinayak\Desktop\v.txt’;

data a1 a2 ;

infile x;

if firstobs=1 and obs=20 then proc print data=a1;

if firstobs=21 and obs=40 then proc print data=a2;

run;

proc print data=a1 a2;

run;

Page 15: SAS Interview Questions

32. Gopi

Posted 8/19/2007 at 9:15 am | Permalink

Hi All,

Can anyone explain about:

Proc LIFETEST and Proc GLM

33. madhu

Posted 9/21/2007 at 8:26 am | Permalink

Q:what is the difference between dsd and missover?

Q:with out data set name create data set ? it is possible?

34. AKA

Posted 12/11/2007 at 6:10 pm | Permalink

Q:what is the difference between dsd and missover?

missover prevents a sas program from going to a new input line if it doesnot find values in

the current line for all the input variables.

Q:with out data set name create data set ? it is possible?

data _NULL_;

35. AKA

Posted 12/11/2007 at 6:55 pm | Permalink

Page 16: SAS Interview Questions

# How does SAS handle missing values in: assignment statements, functions, a merge, an

update, sort order, formats, PROCs?

# How many missing values are available? When might you use them?

# How do you test for missing values?

# How are numeric and character missing values represented internally?

36. AKA

Posted 12/11/2007 at 6:56 pm | Permalink

# How do you make use of functions?

# When looking for contained in a character string of 150 bytes, which function is the best to

locate that data: scan, index, or indexc?

# What is the significance of the ‘OF’ in X=SUM(OF a1-a4, a6, a9);?

# What do the PUT and INPUT functions do?

# Which date function advances a date, time or date/time value by a given interval?

# What do the MOD and INT function do?

# How might you use MOD and INT on numerics to mimic SUBSTR on character strings?

# In ARRAY processing, what does the DIM function do?

# How would you determine the number of missing or nonmissing values in computations?

# What is the difference between: x=a+b+c+d; and x=SUM(a,b,c,d);?

# There is a field containing a date. It needs to be displayed in the format “ddmonyy” if it’s

before 1975, “dd mon ccyy” if it’s after 1985, and as ‘Disco Years’ if it’s between 1975 and

1985. How would you accomplish this in data step code? Using only PROC FORMAT.

# In the following DATA step, what is needed for ‘fraction’ to print to the log? data _null_;

x=1/3; if x=.3333 then put ‘fraction’; run;

# What is the difference between calculating the ‘mean’ using the mean function and PROC

MEANS?

37. Gowri

Posted 1/10/2008 at 2:55 am | Permalink

When looking for contained in a character string of 150 bytes, which function is the best to

locate that data: scan, index, or indexc?

Ans: INDEX function. Scan just sub strings the data and INDEXC looks for one char.

# What is the significance of the ‘OF’ in X=SUM(OF a1-a4, a6, a9);?

Ans: Without OF this will be sonsidered as subtraction. I mean a4 will be subtracted from a1.

Page 17: SAS Interview Questions

# What do the PUT and INPUT functions do?

Ans: PUT converts Numeric to character and INPUT converts Character to Numeric explicitly

Which date function advances a date, time or date/time value by a given interval?

Ans: INTNX

In the following DATA step, what is needed for ‘fraction’ to print to the log?

data _null_; x=1/3; if x=.3333 then put ‘fraction’; run;

Ans: FRACTw. format cna be used to accomplish this

38. David

Posted 5/1/2008 at 10:26 pm | Permalink

1.What SAS statements would you code to read an external raw data file to a DATA step?

Answer: INFILE statement is used to read the external raw data fiel to a Data Step.

2. How do you read in the variables that you need?

Answer: List the variable names after INPUT statement.

3. Are you familiar with special input delimiters? How are they used?

Answer: Yes, Using INPUT statement and DLM=option and DSD optin to read delimited file.

4. If reading a variable length file with fixed input, how would you prevent SAS from reading

the next record if the last variable didn’t have a value?

Answer: Using MISSOVER option in INFILE statement.

5. What is the difference between an informat and a format? Name three informats or

formats.

Answer: Informat gives SAS special instruction for reading a variable, and Format gives SAS

special instruction for writing a variable.

For example: DATEw. w. w.d

6. Name and describe three SAS functions that you have used, if any?

Answer: DAY(date) Today() SUBSTR(ARG,POSITION,N)SUM()

7. How would you code the criteria to restrict the output to be produced?

Answer: Using WHERE statement

8. What is the purpose of the trailing @? The @@? How would you use them?

Answer: Both are line hold specifiers, the difference is how long they hold a line for input,

The trailing@ is used to hold the line of the raw data for subsequent INPUT statements, but

releases that line when SAS returns to the top of DATA step, the trailing @@ will hold the

line even when SAS starts build a new obsrvation.

9. Under what circumstances would you code a SELECT construct instead of IF statements?

Answer:

10. What statement do you code to tell SAS that it is to write to an external file?

Answer: Using _null_ statement

11. What statement do you code to write the record to the file?

Answer: Using FILE and PUT statements

Page 18: SAS Interview Questions

12. If reading an external file to produce an external file, what is the shortcut to write that

record without coding every single variable on the record?

Answer: Using EXPORT procedure

13. If you’re not wanting any SAS output from a data step, how would you code the

data statement to prevent SAS from producing a set?

Answer: _NULL_

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

Answer: Where statement

15. 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.

16. How would you include common or reuse code to be processed along with your

statements?

MICRO

39. jyotsna.G

Posted 6/25/2008 at 5:15 am | Permalink

1.what is the difference between dsd and missover?

2.Give some information about _IOSC_ ?

3.What is the role of _n_ and _null_ ?

40. ajay sinha

Posted 6/27/2008 at 8:36 pm | Permalink

1)What SAS statements would you code to read an external raw data file to a DATA step?

ans)infile statement

2)How do you read in the variables that you need?

ans)use var

like proc print data=er;

var num;

run;

3)Are you familiar with special input delimiters? How are they used?

ans)yes . dlm=’,'; or dlm=’ ‘;etc

4)If reading a variable length file with fixed input, how would you prevent SAS from reading

the next record if the last variable didn’t have a value?

Page 19: SAS Interview Questions

ans)use specific length or format

like input num 9. char $5.;

5)What is the difference between an informat and a format? Name three informats or

formats.

ans)informat is used to print the data from the dataset by ommitng some values whereas

format reads a data differntly then what is actually stored in the dataset by adding our own

values.

date, ddmmyy and worddate

6)Name and describe three SAS functions that you have used, if any?

ans)a=sum(a,b,c);

s=log(a);

d=lag(a);

7)How would you code the criteria to restrict the output to be produced?

ans) use format

8)What is the purpose of the trailing @? The @@? How would you use them?

ans)@ is coulmn pointer to get the specific value while @@ is used if variables are less and

value are more and u want to read each value

input @ ‘content:’ a 9. b 5.;

input a b c @@;

9)Under what circumstances would you code a SELECT construct instead of IF statements?

ans) when u want to use a group

10)What statement do you code to tell SAS that it is to write to an external file?

ans)ods or datafile

11)What statement do you code to write the record to the file?

ans)dde

12)If reading an external file to produce an external file, what is the shortcut to write that

record without coding every single variable on the record?

ans)dde and ods

13)If you’re not wanting any SAS output from a data step, how would you code the

data statement to prevent SAS from producing a set?

ans) data _null_;

14)What is the one statement to set the criteria of data that can be coded in any step?

ans)set

15)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.

ans)use macro

16)How would you include common or reuse code to be processed along with your

statements?

ans)using format

17)When looking for data contained in a character string of 150 bytes, which function is the

best to locate that data: scan, index, or indexc?

ans)scan

18)If you have a data set that contains 100 variables, but you need only five of those, what is

the code to force SAS to use only those variable?

ans)in input statement use only those variables name which u want.

Page 20: SAS Interview Questions

19)Code a PROC SORT on a data set containing State, District and County as the primary

variables, along with several numeric variables.

ans)proc sort data=q;

by state;

run;

similarly other statements

20)How would you delete duplicate observations?

ans)using dupkey

21)How would you code a merge that will keep only the observations that have matches from

both sets.

ans)usning merge and dupkey

22)How would you code a merge that will write the matches of both to one data set, the non-

matches from the left-most data set to a second data set, and the non-matches of the right-

most data set to a third data set.

ans)merge , dupkey and nodupkey

23)What is the Program Data Vector (PDV)? What are its functions?

ans)memory that sas creates while running the sas program in compilation stage is called

PDV,

24)Does SAS ‘Translate’ (compile) or does it ‘Interpret’?

Explain.

ans)compile with creating PDV

25)At compile time when a SAS data set is read, what items are created?

ans)variables

26)Name statements that are recognized at compile time only?

ans)data

27)Identify statements whose placement in the DATA step is critical.

ans)run;

28)Name statements that function at both compile and execution time.

ans)run;

29)Name statements that are execution only.

ans)proc;

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

ans)creating the name of dataset.

31)What is _n_?

ans)new line

41. San

Posted 8/4/2008 at 3:32 am | Permalink

I have mentioned the correct answer for some Q. David and Ajay has already mentioned the

correct answer for the other Qs.

Page 21: SAS Interview Questions

4)If reading a variable length file with fixed input, how would you prevent SAS from reading

the next record if the last variable didn’t have a value?

Use MISSOVER while the file is read

INFILE datalines MISSOVER;

5)What is the difference between an informat and a format? Name three informats or

formats.

Format is used to print the output in the desired format

e.g., date9. comma9. DDMMYY10.

Informat is used with the input file which helps to read the data in the desired format to use

it inside the program for valuation

INFORMATs can be used with the INPUT() function, and FORMAT with the PUT() function.

8)What is the purpose of the trailing @? The @@? How would you use them?

SAS provides two line-hold specifiers.

The trailing at sign (@) holds the input record for the execution of the next INPUT statement.

The double trailing at sign (@@) holds the input record for the execution of the next INPUT

statement, even across iterations of the DATA step.

input Name $20. @; or input Name $20. @@;

9)Under what circumstances would you code a SELECT construct instead of IF statements?

When you have a long series of mutually exclusive conditions and the comparison is numeric,

using a SELECT group is slightly more efficient than using a series of IF-THEN or

IF-THEN/ELSE statements because CPU time is reduced. SELECT groups also make the

program easier to read and debug.

10)What statement do you code to tell SAS that it is to write to an external file?

Using FILE statement we can write the data from the external file. INFILE for reading the

data from the external file

11)What statement do you code to write the record to the file?

Using PUT statement or OUTPUT statement

18)If you have a data set that contains 100 variables, but you need only five of those, what is

the code to force SAS to use only those variable?

List Input

19)Code a PROC SORT on a data set containing State, District and County as the primary

variables, along with several numeric variables.

proc sort data=q;

by state District County;

run;

31)What is _n_?

No of times the data step executed.

42. saibabu

Posted 9/8/2008 at 3:57 am | Permalink

Page 22: SAS Interview Questions

hi,

i have 100 observations from that i want to create 5 datasets like a1,a2,a3,a4,a5.Each data

set should contain 20 observation each.For ex.a1 would contain 1 to 20 obs and a2 would

contain 21-40 like that…

data a1 a2 a34 a4 a5;

set xxx;

if 1 le _n_ le 20 then ouput a1;

if 21 le _n_ le 40 then ouput a2;

if 41 le _n_ le 60 then ouput a3;

if 61 le _n_ le 80 then ouput a4;

if 81 le _n_ le 100 then ouput a5;

run;

POST A COMMENT

Your email is never published nor shared. Required fields are marked *

Name *

Email *

Website

Comment

Ads by Google

A-lign CPAs - SAS 70

Global SAS 70 Audit Specialists Free quote: call +44.845.869.7554

www.aligncpa.com

SAS Courses & Institutes

Find Top SAS Institutes in India. Get Info on Courses,Admission,Fees.

Post Comment 152

152 0

Page 23: SAS Interview Questions

www.Shiksha.com/SAS-Courses

Job Interview Question Articles C# Interview Questions and Answers

QTP Interview Questions and Answers

C++ Interview Questions and Answers

PHP Interview Questions and Answers

XML Interview Questions and Answers

JavaScript Interview Questions and Answers

Asp.Net Interview Questions and Answers

J2EE Interview Questions and Answers

ABAP Interview Questions and Answers

Perl Interview Questions and Answers

Java Interview Questions and Answers

Resources Technology Question and Answer Website

How to dance around the salary-expectation question

10 mistakes managers make during job interviews

ID Maker

Stupid interview questions

How to Answer These Tricky Interview Questions

Seven tips for writing an online profile for LinkedIn, MySpace or Facebook

Video surveillance

Ink cartridges

Laptop computers

Affordable life insurance

Ink cartridges

Tutorials AJAX Tutorials

Dealing with your job

Getting a job

JavaScript tutorials

Job interview tips from Yahoo! HotJobs

MySQL tutorials

Retiring from your job

Ruby on Rails tutorials

Salary guide for IT jobs

Self-employment

TechInterviews guides in PDF

Understanding pointers

XML Tutorials

XUL tutorials

RSS Feeds All posts

All comments

Page 24: SAS Interview Questions

Powered by WordPress. Built on the Thematic Theme Framework.

B est m atches f or i nterview q uestions o n B I S AS

(x)…more i mproved v ersion f rom s as w ith r espect t o B I t

ools a nd w ith m any a dvanced f eatures. J ump t o t ext »