Does anzone help me out how to change the title stement in the output window based on condition
ex:%global x d;
%let x=ccc;
%let date=23may2014;
data test;
input var1 date;
datalines;
aaa 21may2014
bbb 22may2014
ccc 23may2014
run;
Title "................";
proc print;
run;
Here i need if x=var1 and d=date then title="CCCCCCCCCCCCCCCCCCCCCC"
if x ne var1 and d=date then title="BBBBBBBBBBBBBBBBBBBBB"
if x ne var1 and d ne date then title="VVVVVVVVVVVVVVVVV";
Thanks in advance....
Hi,
Use call execute in your datastep.
data ...;
call execute('title "'||strip(your title)||'";');
call execute('proc print...');
run;
Since you cannot change the title while proc print is running, and you placed the condition on values of the dataset to be printed, your problem is unsolvable.
Make a macro :
%global x d; %let x=ccc; %let date=23may2014; %let flag=N; data test; input var1 $ date :$20.; if var1="&x" then call symputx('flag','Y'); datalines; aaa 21may2014 bbb 22may2014 ccc 23may2014 run; %macro m; %if &flag eq Y %then %do; Title "YES.............."; %end; %else %do;title "NO...."; %end; proc print; run; %mend m; %m
Xia Keshan
Well, you do have to understand that you have three observations, but there can only be one title. Assuming you work out which of the three observations determines the title ...
You can create a macro variable holding the title's text, instead of writing a macro. Right before the DATALINES statement, add along these lines:
if var1="&x" and d="&date" then call symput('text', 'CCCCCCCCCCCCCCCCCCCCCCC');
else if var1 ne "&x" and d="&date" then call symput('text', 'BBBBBBBBBBBBBBBBBBBBBBB');
else call symput('text', 'VVVVVVVVVVVVVVVVVVVVVVVVV');
Then below, your TITLE statement simply becomes:
title "&text";
Good luck.
The closest you might get is to create your "title" variable and then
proc print;
by title;
run;
Depending on the version of SAS you are using there are options to modify the appearance of the By line that will appear before the printed data.
Hi all,
Thank you so much for your response.I tried all above,espesially programs by Ksharp and Astounding It was executed successfullz without anz errors,But it did not give the expected resulz.Itäs not able to change the title statement.Could zou guide me more please.
Thanks,
Rawindarreddy
As was already stated, you CANNOT change the title during execution of a proc or data step. You can just try to simulate it.
One way to achieve the desired result is to generate the whole output manually with a data _null_ step. But this means you have to write the whole report syntax in eg html. Which takes knowledge in css, html and the intricacies of the put statement.
Post an example of what your data looks like and EXACTLY what you expect to see as the output and we can help you get there. The way your question is currently phrased it won't work, however there may be other solutions, some easier than others to get what you want.
You will have to show more of your program. What are all the details of your PROC PRINT? What are you hoping will happen?
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.