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
SAS Super FREQ
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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 851 views
  • 0 likes
  • 3 in conversation