BookmarkSubscribeRSS Feed
deleted_user
Not applicable
just wanted to share the "out of the box" moment.
&SYSINDEX is clearly documented "You can use SYSINDEX in a program that uses macros when you need a unique number that changes after each macro invocation."
I wanted a unique number when some conditions occurred in a macro and thought of &SYSINDEX. but it only created a constant 😞 .
This time the light bulb switched on and I saw out of the box 😉 I should use %SYSINDEX .
OK, I know that does not exist, but it is simple enough to create[pre] %macro sysindex ;
&sysindex
%mend sysindex ;[/pre]So I only needed to change that "&" prefix into "%" before the SYSINDEX and obtained exactly what I needed.
Every invocation of %sysindex provides a unique number for the SAS session. 🙂

regards to the Forum

PeterC
3 REPLIES 3
data_null__
Jade | Level 19
Alternatively:

[pre]
%sysfunc(monotonic())
[/pre]

More typing but then you don't need to maintain a macro that provides very little function.
deleted_user
Not applicable
having the %SYSINDEX feels better, as it is a good match for the documentation.
In on-line help and Doc, I can't find monotonic.
On SAS Support site, it is declared as not supported in SQL

So I feel more confident about leaving %sysindex in client autocall libraries.
Would you not agree?

PeterC
PatrickG
SAS Employee
The monotonic() function is undocumented (which is why you can't find it!). This is because it can be problematic and produce unexpected results in some cases, e.g. when used within PROC SQL. So if you go that route, be careful!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 931 views
  • 0 likes
  • 3 in conversation