There are 200 observations in a dataset, i want to pull out
the observation no's 100, 150,180,190 by using Proc SQL? How
you can get it?

Answers were Sorted based on User's Feedback



There are 200 observations in a dataset, i want to pull out the observation no's 100, 150,180,..

Answer / limnesh

Proc Sql;
Select *,monotonic ()as c from <datasetname>
group by a having c in (100,150,180,190);
quit;

Is This Answer Correct ?    20 Yes 5 No

There are 200 observations in a dataset, i want to pull out the observation no's 100, 150,180,..

Answer / limnesh dominic

Before saying answer is not correct, please try this
Data f;
do i=1 to 200;
output;
end;
run;

Proc Sql;
Select *,monotonic ()as c from f
group by i having c in (100,150,180,190);
quit;

Proc print;
run;

Is This Answer Correct ?    15 Yes 0 No

There are 200 observations in a dataset, i want to pull out the observation no's 100, 150,180,..

Answer / jim

* Setup test data;
data test;
do i=1 to 200;
j=ranuni(i);
output;
end;
run;

Proc Sql;
Select *,monotonic ()as c from test
having c in (100,150,180,190);
quit;

Is This Answer Correct ?    8 Yes 0 No

There are 200 observations in a dataset, i want to pull out the observation no's 100, 150,180,..

Answer / pranoy tikadar

PROC SQL;
SELECT*,
MONOTONIC() AS COUNT
FROM TEST
HAVING COUNT IN(100,150,180,190);
QUIT;

Is This Answer Correct ?    11 Yes 3 No

There are 200 observations in a dataset, i want to pull out the observation no's 100, 150,180,..

Answer / vipin choudhary

Proc Sql;
Select * from <dataset name>
where _n_ in (100,150,180,190);
quit;

Is This Answer Correct ?    12 Yes 29 No

Post New Answer

More SAS Interview Questions

How to merge the data using merge statement and proc format? Is the result is same ?

2 Answers  


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

6 Answers   Accenture,


In which format does Date stores in sas..? What is the use of DATE in SAS.?

3 Answers   TCS,


What is connection profile? : sas-grid-administration

0 Answers  


Define run-group processing?

0 Answers  






What are all the problems you faced while validating tables and reports?

0 Answers   Accenture, Quintiles,


do you need to know if there are any missing values? : Sas programming

0 Answers  


what are the softwares and applications that are used most frequently used by sas bi applications developers? : Sas-bi

0 Answers  


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

8 Answers   D&B,


How to read multiple excel sheets from a single excel file at once????

7 Answers   HCL, Verinon Technology Solutions,


Describe a time when you were really stuck on a problem and how you solved it?

1 Answers  


what is the Population you used in your project, is it ITT or PP?

0 Answers   Accenture, Quintiles,


Categories