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.
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.
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.
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.
Thanks. Tried with dictionary.columns and it worked.
There is nothing to concatenate:
data want; set sashelp.vcolumn; where libname="WORK" and memname in ("ABC","DEF"); run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.