The SAS Output Delivery System and reporting techniques

Concatenating multiple datasets vertically into the same dataset using ODS output.

Accepted Solution Solved
Reply
New Contributor
Posts: 4
Accepted Solution

Concatenating multiple datasets vertically into the same dataset using ODS output.

[ Edited ]

I am trying to create one dataset(pos) from 2 datsets (abc , def) like below

member    variable  num

----------    ----------   ------

abc           avar1        1

abc           avar2        2

def            dvar1        1

def            dvar2        2

.

.

.

 

using ods statement

ods output position=pos (keep=member variable num where=(num<=2));
proc contents data=abc varnum;
run;
ods output close;

ods output position=pos (keep=member variable num where=(num<=2));
proc contents data=def varnum;
run;
ods output close;

 

My problem is when I run the second ods output staement for 'def' , it overwrites the 'pos' dataset that was created for 'abc' dataset.

i want to concatenate the outputs of 2 ods statements vertically into one dataset.


Accepted Solutions
Solution
‎04-16-2016 09:33 AM
Super User
Posts: 5,257

Re: Concatenating multiple datasets vertically into the same dataset using ODS output.

Using ODS to output data is a great possibility. Which I use only when I can't get the data I want any "regular way".

What I can see from your desired output, this information is available directly in SASHELP.VCOLUMN and DICTIONARY.COLUMNS.

Data never sleeps

View solution in original post


All Replies
Super User
Posts: 6,939

Re: Concatenating multiple datasets vertically into the same dataset using ODS output.

ODS OUTPUT creates a new dataset, therefore the old dataset is overwritten.

Use two different dataset names in the ODS OUTPUT statements and concatenate them later with a data step, or do not close/reopen the ODS destination.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Solution
‎04-16-2016 09:33 AM
Super User
Posts: 5,257

Re: Concatenating multiple datasets vertically into the same dataset using ODS output.

Using ODS to output data is a great possibility. Which I use only when I can't get the data I want any "regular way".

What I can see from your desired output, this information is available directly in SASHELP.VCOLUMN and DICTIONARY.COLUMNS.

Data never sleeps
New Contributor
Posts: 4

Re: Concatenating multiple datasets vertically into the same dataset using ODS output.

Thanks. Tried with dictionary.columns  and it worked.

Super User
Super User
Posts: 7,401

Re: Concatenating multiple datasets vertically into the same dataset using ODS output.

There is nothing to concatenate:

data want;
  set sashelp.vcolumn;
  where libname="WORK" and memname in ("ABC","DEF");
run;
☑ This topic is SOLVED.

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

Discussion stats
  • 4 replies
  • 383 views
  • 2 likes
  • 4 in conversation