DATA Step, Macro, Functions and more

Just wanted to retries multiple range of rows from same table

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

Just wanted to retries multiple range of rows from same table

proc sql ;

CREATE TABLE WORK AS

select *

from cecl.ar_model_v_20170630

where (firstobs = 100 obs = 200) & (first obs = 400 obs = 500) ;

quit;


Accepted Solutions
Solution
‎10-17-2017 01:51 PM
Esteemed Advisor
Posts: 5,625

Re: How to retrieve multiple range of rows from same table

Posted in reply to skamal12000

With SQL:

 

proc sql;
CREATE TABLE WORK AS
select * from cecl.ar_model_v_20170630(firstobs=100 obs=200)
union all
select * from cecl.ar_model_v_20170630(firstobs=500 obs=600);
quit;
PG

View solution in original post


All Replies
New Contributor
Posts: 3

How to retrieve multiple range of rows from same table

Posted in reply to skamal12000

%let cecl =/sas/model/model_dev/enterprise_inputs/published_data/cecl/M201706;

libname cecl "&cecl";

 

proc sql ;

CREATE TABLE WORK AS

select *

from cecl.ar_model_v_20170630

where (firstobs = 100 obs = 200) & (first obs = 400 obs = 500) ;

quit;

 

like try to retrieve row number 100 to 200 and then 500 to 600 from same table

Super User
Posts: 24,010

Re: How to retrieve multiple range of rows from same table

[ Edited ]
Posted in reply to skamal12000

Try a data step instead. SQL doesn't have a good way to extract specific rows.

 

data want;
set have;

if 100 <= _n_ <=300 or  400 <= _n_ <= 900;

run;

 


skamal12000 wrote:

%let cecl =/sas/model/model_dev/enterprise_inputs/published_data/cecl/M201706;

libname cecl "&cecl";

 

proc sql ;

CREATE TABLE WORK AS

select *

from cecl.ar_model_v_20170630

where (firstobs = 100 obs = 200) & (first obs = 400 obs = 500) ;

quit;

 

like try to retrieve row number 100 to 200 and then 500 to 600 from same table



 

Super User
Posts: 24,010

Re: How to retrieve multiple range of rows from same table

Posted in reply to skamal12000
Please do not post the same question multiple times.
Solution
‎10-17-2017 01:51 PM
Esteemed Advisor
Posts: 5,625

Re: How to retrieve multiple range of rows from same table

Posted in reply to skamal12000

With SQL:

 

proc sql;
CREATE TABLE WORK AS
select * from cecl.ar_model_v_20170630(firstobs=100 obs=200)
union all
select * from cecl.ar_model_v_20170630(firstobs=500 obs=600);
quit;
PG
New Contributor
Posts: 3

Re: Just wanted to retries multiple range of rows from same table

Posted in reply to skamal12000

Thank you so much for your help. I am very new to SAS database.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 175 views
  • 2 likes
  • 3 in conversation