DATA Step, Macro, Functions and more

how to add two titles seperately in a dataset

Accepted Solution Solved
Reply
Contributor
Posts: 28
Accepted Solution

how to add two titles seperately in a dataset

Hello,

 

I want to combine two dataset: PL and PLC vertically,

so I use the

data all;

set PL PLC;

run;

 

I hope the output will show: a title for PL and a title for PLC in one dataset , does anyone know how and where can I add that please?

 

Thank you


Accepted Solutions
Solution
‎01-18-2017 10:00 AM
Super User
Posts: 19,789

Re: how to add two titles seperately in a dataset

Posted in reply to septemberbulb

Titles don't exist within a dataset, only for reports. 

 

Look at Example 2

 

https://support.sas.com/documentation/cdl/en/lestmtsref/69738/HTML/default/viewer.htm#p10gcmrmf83iax...

 

You will need a variable to differentiate the datasets, look at the INDSNAME option to capture the name of the dataset. 

 

Data all;

length source dsname $50.;

set pl plc INDSNAME=source;

dsname=source;

run;

View solution in original post


All Replies
Solution
‎01-18-2017 10:00 AM
Super User
Posts: 19,789

Re: how to add two titles seperately in a dataset

Posted in reply to septemberbulb

Titles don't exist within a dataset, only for reports. 

 

Look at Example 2

 

https://support.sas.com/documentation/cdl/en/lestmtsref/69738/HTML/default/viewer.htm#p10gcmrmf83iax...

 

You will need a variable to differentiate the datasets, look at the INDSNAME option to capture the name of the dataset. 

 

Data all;

length source dsname $50.;

set pl plc INDSNAME=source;

dsname=source;

run;

Super User
Posts: 5,503

Re: how to add two titles seperately in a dataset

Posted in reply to septemberbulb

Reeza's tools can help, but you may need some programming as well.  You may need to add a variable to the data set that holds the text you want to insert into the title (possibly the entire text, as in this example below).

 

data want;

set PL (in=in1) PLC (in=in2);

length title_text $ 50;

if in1 then title_text = 'I want to use this title for the PL observations';

else title_text = 'Exceptions were also added by the PLC observations';

run;

 

Then you can use this text as titles by adding a BY statement and #BYVAL:

 

proc print data=want;

by title_text notsorted;

title '#BYVAL1';

run;

 

So SAS isn't really built to do what you ask, but you can work around that even without using ODS.

Contributor
Posts: 28

Re: how to add two titles seperately in a dataset

Posted in reply to Astounding
thank you. learned a lot
☑ This topic is solved.

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

Discussion stats
  • 3 replies
  • 274 views
  • 1 like
  • 3 in conversation