BookmarkSubscribeRSS Feed
Robois
Calcite | Level 5

Hi!

I would like SAS 9.4 to put automatically the name of the data set I'm running on the title of SAS output/results viewer. How to do it?

 

This is an example of the code I'm running:

 

libname Experiment 'O:\MAINFOLDER\SUBFOLDER\SAS library';
PROC IMPORT OUT= Experiment.measurements DATAFILE= "O:\MAINFOLDER\SUBFOLDER\filename.xlsx"
DBMS=XLSX REPLACE;
SHEET="SAS";
GETNAMES=YES;
RUN;

 

PROC PRINT data=Experiment.measurements;
title 'Data set Experiment.measurements all observations';
run;

 

So how do I make SAS automatically to change the title text marked with red to match the current data set I'm running? It's to time consuming to change all the titles manually when changing from one data set to another!

 

Thanks for any help Smiley Happy

3 REPLIES 3
andreas_lds
Jade | Level 19

Maybe i missed something, but aren't libref limited to 8 chars and datasets to 32 chars?

 

SAS saves the name of the last dataset created by datastep or proc in the macro-variable SYSLAST. So changing the title-statement to

title "Dataset &SYSLAST all obs";

should solve the problem.

Robois
Calcite | Level 5
The &SYSLAST macro-variable didn't work. It just returns a output with title 'Data set &SYSLAST all observations'. Any other ideas?



You are probably right about the character limits. However, I just made those up just for this example, so in reality I use different - shorter - names.


Cynthia_sas
Diamond | Level 26
The difference between your TITLE statement and the solution TITLE statement is that you used single quotes. &SYSLAST will NOT resolve when it is enclosed within single quotes. It needs to be resolved within double quotes.

Cynthia

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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