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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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