BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
pambardar
Fluorite | Level 6

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.

1 ACCEPTED SOLUTION

Accepted Solutions
LinusH
Tourmaline | Level 20

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

4 REPLIES 4
Kurt_Bremser
Super User

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.

LinusH
Tourmaline | Level 20

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
pambardar
Fluorite | Level 6

Thanks. Tried with dictionary.columns  and it worked.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

There is nothing to concatenate:

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

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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