BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Vinz867
Fluorite | Level 6

I am creating an HTML file with results from different datasets. However, Data_C always shows up twice - once before the title where the output title is "Data B" and once at the end. How can I stop Data_C from showing up before Data B? TIA!

 

data _null_;
as_of_date = today();
year=year(today());

call symput('as_of_date',"'" || put(as_of_date,mmddyy10.) || "'");
call symput('Year',compress(year));
run;

%put &as_of_date;
%put &year;

proc sql noprint;
select count(*) into: countofpop
from population;
quit;
%put &countofpop;


proc print;
title "Count:" &countofpop.;
quit;

 

proc print data=DATA_B;
title "Data B";
quit;

 

proc print data=Data_B;
var ColumnX;
title "Data B Column";
quit;

 

proc print data=Data_C;
title "Data C";
quit;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
proc print;
title "Count:" &countofpop.;
quit;

This will print the most recent data set (also no quit with a proc print, it's a run). 

 

If you want that title you can use ODS TEXT= or multiple TITLE statements. 

I also recommend the quote function for adding quotes, though I question if those are actually needed.

 

data _null_;
as_of_date = today();
year=year(today());

call symput('as_of_date', quote(put(as_of_date,mmddyy10.)) );
call symput('Year',compress(year));
run;

%put &as_of_date;
%put &year;


proc sql noprint;
select count(*) into: countofpop
from population;
quit;
%put &countofpop;



ods text= "Count:" &countofpop.;

title "Data B";
proc print data=DATA_B;
run;

 
title "Data B Column";
proc print data=Data_B;
var ColumnX;
run;

 
title "Data C";
proc print data=Data_C;
run;

 

View solution in original post

2 REPLIES 2
ballardw
Super User

The first proc print you show does not reference a data set to use.

So it defaults to using the last data set created before that Print executes. Which might be Data_C.

proc print;
title "Count:" &countofpop.;
quit;

proc print data=DATA_B;
title "Data B";
quit;
Reeza
Super User
proc print;
title "Count:" &countofpop.;
quit;

This will print the most recent data set (also no quit with a proc print, it's a run). 

 

If you want that title you can use ODS TEXT= or multiple TITLE statements. 

I also recommend the quote function for adding quotes, though I question if those are actually needed.

 

data _null_;
as_of_date = today();
year=year(today());

call symput('as_of_date', quote(put(as_of_date,mmddyy10.)) );
call symput('Year',compress(year));
run;

%put &as_of_date;
%put &year;


proc sql noprint;
select count(*) into: countofpop
from population;
quit;
%put &countofpop;



ods text= "Count:" &countofpop.;

title "Data B";
proc print data=DATA_B;
run;

 
title "Data B Column";
proc print data=Data_B;
var ColumnX;
run;

 
title "Data C";
proc print data=Data_C;
run;