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 incremental update ? is this possible in SAS OLAP CUBE STUDIO.

1 Answers   TCS,


what is the difference between the SAS v8 and SAS v9?

7 Answers   TCS,


how to extract data from SAP servers? Is like oracle servers or any other methods to extract please reply me.

1 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 its between 1975 and 1985. How would you accomplish this in data step code? Using only PROC FORMAT.

3 Answers   CTS,


what is the formula to measure Baseline

3 Answers   Sristek,


Hot to suppress characters from a given string?

4 Answers   CTS,


what are the best practices to process the large data sets in sas programming? : Sas-administrator

0 Answers  


In this question, I rename the numeric variable phone to numphone and then try use phone=put(numphone,comma16.) to store the numeric value numphone as a string value in phone. But I get a warning tha numphone already exists and in the data sat phone doesnt exist and numphone is set to missing. Why? data names_and_more; input Name $20. Phone : comma16. Height & $10. Mixed & $8.; Name = tranwrd(Name,' ',' '); rename phone = numphone; phone = put(numphone,comma16.); datalines; Roger Cody 9,087,821,234 5ft. 10in. 50 1/8 Thomas Jefferson 3,158,488,484 6ft. 1in. 23 1/2 Marco Polo 8,001,234,567 5Ft. 6in. 40 Brian Watson 5,183,551,766 5ft. 10in 89 3/4 Michael DeMarco 4,452,322,233 6ft. 76 1/3 ;

1 Answers  


How necessary is it to be creative in your work?

0 Answers   Oracle,


I Here clinical SAS training by Ramesh Azmeera is good. Is it confirm ?

2 Answers  


explain about various caches available in data integrator? : Sas-di

0 Answers  


How do you write a test plan?

1 Answers   Oracle,


Categories