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

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

6 Answers  


describe about metadata object? : Sas-di

0 Answers  


how many types prompting framework can be broken down to? : Sas-bi

0 Answers  


how do i get last 10obs from a dataset when we don't know about the number of obsevations in that dataset?

7 Answers   TCS,


What are the new features included in the new version of SAS Programming Language?

0 Answers  






Compare sas with other data analytics tools.

0 Answers  


in ods is there any lib's

2 Answers   SAS,


What is the purpose of trailing @ and @@? How do you use them?

0 Answers  


What is interleaving in SAS?

0 Answers  


name the scheduler for scheduling job and explain the scheduler? : Sas-di

0 Answers  


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

2 Answers  


What function CATX syntax does?

0 Answers  


Categories