Solved
New Contributor
Posts: 4

# Needed one output for ds

I have 2 datasets with data
Ds1
1
2
3
Ds2
4
5
6

And I want output like below :
1
4
2
5
3
6

Can anyone help me out for this problem

Accepted Solutions
Solution
3 weeks ago
PROC Star
Posts: 1,400

## Re: Needed one output for ds

Ah ok. Do like this instead.

``````data ds1;
input x @@;
datalines;
1 2 3
;

data ds2;
input x @@;
datalines;
4 5 6
;

data want;
do i=1 to max(nobs1,nobs2);
set ds1 nobs=nobs1 point=i; output;
set ds2 nobs=nobs2 point=i; output;
end;
stop;
run;``````

All Replies
PROC Star
Posts: 1,400

## Re: Needed one output for ds

Assuming the variables have the same name (In this example x)

``````data ds1;
input x @@;
datalines;
1 2 3
;

data ds2;
input x @@;
datalines;
4 5 6
;

data want;
set ds1 ds2;
run;``````
New Contributor
Posts: 4

## Re: Needed one output for ds

Hi

But for your sol the output will be like

1
2
3
4
5
6

But I need the output like below
1
4
2
5
3
6

Which is taking first observation from Ds1 and first observation from Ds2 like that it follows
Solution
3 weeks ago
PROC Star
Posts: 1,400

## Re: Needed one output for ds

Ah ok. Do like this instead.

``````data ds1;
input x @@;
datalines;
1 2 3
;

data ds2;
input x @@;
datalines;
4 5 6
;

data want;
do i=1 to max(nobs1,nobs2);
set ds1 nobs=nobs1 point=i; output;
set ds2 nobs=nobs2 point=i; output;
end;
stop;
run;``````
New Contributor
Posts: 4

thanks dude
PROC Star
Posts: 1,400

Anytime

Super User
Posts: 2,050

## Re: Needed one output for ds

``````data ds1;
input x @@;
datalines;
1 2 3
;

data ds2;
input x @@;
datalines;
4 5 6
;

data want(keep=x);
set ds1; set ds2(rename=(x=x1));
output;
x=x1;
output;
run;``````
☑ This topic is solved.