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 do user inputs and command line arguments in sas?

0 Answers   D&B, TCS,


what is the difference between floor and ceil functions in sas? : Sas-administrator

0 Answers  


How would you invoke a macro? : sas-macro

0 Answers  


What is the difference between match merge and one to one merge?

0 Answers  


what is sas data set?

0 Answers  






What is the difference between SAS Data step and SAS PROC SQL, and which is better?

1 Answers   TCS,


what is Difference between PROC SQL JOINS and MERGE?

3 Answers   Accenture, Wipro,


I need help in merging two different datasets. I am merging by date and I want to propagate observations from one dataset to the corresponding dates. One dataset has a unique date for each day of the month, while the other dataset has same date for different patient visits. For example I want to spread an observation on the 31DEC2008 from one dataset to several observations with the same date on a second dataset for all the patients who visited on that date. I have tried to merge the two and the result is not what I wanted. Instead I get a dataset whereby all the dates have missing values where observations from the first datset should have spread.

1 Answers  


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

7 Answers   HCL, Verinon Technology Solutions,


Give an example where SAS fails to convert character value to numeric value automatically?

0 Answers  


How do you control the number of observations and/or variables read or written?

0 Answers  


Explain the message 'Merge has one or more datasets with repeats of by variables'.

5 Answers  


Categories