BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.

I know if I put the following Proc Print in my code, it will print the data for the last dataset created (previous dataset):

Proc print;

run;

But what I'd really like to do is put that in a macro with that grabs the name of the last dataset created and puts it into a TITLE statement. Is there a way to know the name of the dataset that was created?

Thanks,

J

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

Have you tried using the automatically created macro variable: &sysdsn. ?

There are a lot of automatically created macro variables that capture things you might want.  Take a look at: http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a001071968.htm

View solution in original post

9 REPLIES 9
art297
Opal | Level 21

Have you tried using the automatically created macro variable: &sysdsn. ?

There are a lot of automatically created macro variables that capture things you might want.  Take a look at: http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a001071968.htm

Haikuo
Onyx | Level 15

sysdsn

Haikuo

Linlin
Lapis Lazuli | Level 10

data class;


set sashelp.class;

proc print data=&syslast;


title from dataset &syslast;

run;

JasonDiVirgilio
Quartz | Level 8

Thanks everyone...sysdsn and syslast both work great...they even include the libname used.

Interestingly, &syslast uses the format "libname.datasetname"

...where &sysdsn uses the format "libname    datasetname"


Peter_C
Rhodochrosite | Level 12

HI Jason

One wish remains unfulfilled. To have a convenient subtitle reporting the data set used in the reporting procedure we still need to submit that subtitle statement.

I would quite like have a feature that resolves when the procedure executes and not just when the title(n) or footnote statement is submitted.

footnote3 "reporting from #latest_ds" ;

I chose the # prefix because something like this used #byVal

just thinking

data_null__
Jade | Level 19

Do you remember the super-duper PROC QPRINT.  It had options to include DSName and or DSLabel in the output

Peter_C
Rhodochrosite | Level 12

vaguely I recall qprint not providing what I needed (at the time) and proc print, did so I restricted that bit of learning (sounds like the well prepared excuse it is).

However didn't qprint become fsprint? forerunner of fsview and fsreport (now proc report)?

there is an excellent certification proposed by ChrisH in his SASDummy blog back at the beginning of this month for which I do not wish to qualify!

😉

😉

data_null__
Jade | Level 19

Peter.C wrote:

vaguely I recall qprint not providing what I needed (at the time) and proc print, did so I restricted that bit of learning (sounds like the well prepared excuse it is).

It is quite possible that QPRINT did not provided what you needed at the time.  I wouldn't know anything about that.

However didn't qprint become fsprint? forerunner of fsview and fsreport (now proc report)?

No.

PGStats
Opal | Level 21

data test;
x=1;
run;

title "Created &SYSLAST";

proc print; run;

PG

PG

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 9 replies
  • 5864 views
  • 6 likes
  • 7 in conversation