BookmarkSubscribeRSS Feed
Ronein
Onyx | Level 15

Hello

Here are some examples to create serial number.

Some of them are working and some not .

I want to refresh my memory why Example1 is working without Retain statement?

Does it mean that there is hidden Retain that is working here even if we didn't write Retain statement?

Will it also work automatically when using sum(seq,1) or just when using seq+1 ?

Data have;
Input profit;
cards;
10
40 
50
;
run;

Data ex1:
set have;
seq+1;
Run;

Data ex2:
set have;
sum(seq,1);
Run;


Data ex3:
set have;
Retain seq 0;
seq+1;
Run;


Data ex4:
set have;
Retain seq 0;
seq=seq+1;
Run;
1 REPLY 1
PaigeMiller
Diamond | Level 26

seq+1; has an implied RETAIN. https://documentation.sas.com/?docsetId=lestmtsref&docsetTarget=n1dfiqj146yi2cn1maeju9wo7ijs.htm&doc...

 

Will it work for  your other examples? Run the code and see!

 
--
Paige Miller

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 1 reply
  • 573 views
  • 0 likes
  • 2 in conversation