DATA Step, Macro, Functions and more

Print multiple datasets with same datasets name and different libraries

Reply
New Contributor
Posts: 2

Print multiple datasets with same datasets name and different libraries

Hi Folks,

 

I have two libraries named in1 & in2 both consist the datasets with same naming convention .For eg: test1 & test1

i.e in1.test1 & in2.test1.

Though the naming convention is same fields inside the datasets may or may not differ.

 

suppose I have added two fields named age and place in the source file. and they will reflect in both the datasets with same or different values ,because they might be separated on basis of key identifiers.

 

Could you please help me how to find the values for added fields w.r.t to library in the same sas program.

 

Thanks

Nitesh

 

Super User
Super User
Posts: 9,599

Re: Print multiple datasets with same datasets name and different libraries

Posted in reply to niteshbharadwaj

Do you just need to "print" them?  If so you can use:

proc report data=in1.test1 nowd;
  columns _all_;
run;

The _all_ will use all available columns.

 

If you need to do something more complicated, then you would consult the metadata tables, e.g. this would get you all variables found in both library in1 and 2, and datasets test1 and 2:

data want;
  set sashelp.vcolumn (where=(libname in ("IN1","IN2") and memname in ("TEST1","TEST2")));
run;
Super User
Posts: 13,583

Re: Print multiple datasets with same datasets name and different libraries

Posted in reply to niteshbharadwaj

Or

 

Proc print data=<any valid data set name>;

run;

 

Will print the entire data set, all values all rows.

 

Or you need to show by concrete example what you mean for output.

 

Once you have created a data set the only way to tell "new" variables, if this is the core of your question and not printing, then you would have to preserve a list of variables from the "old" data set.

Ask a Question
Discussion stats
  • 2 replies
  • 49 views
  • 0 likes
  • 3 in conversation