Hi All,
As mentioned in the subject I came across an issue where I need to assign a new order# for every 3 rows. In the below example the data in the NEW ORDER# variable is how I'm expecting.
Name ORDER NEW ORDER#
ABC 1 1
ACC 2 1
ADC 3 1
AEC 4 2
AFC 5 2
AGC 6 2
AHC 7 3
AIC 8 3
AJC 9 3
If the dataset has few rows i can use if condition or something similar but the dataset I have contains 75 millions rows. So i was wondering how to approach this issue?
It would be great if you could help me with this issue.
Thanks in advance,
RD
data have;
input Name $ ORDER;* NEW ORDER#;
cards;
ABC 1 1
ACC 2 1
ADC 3 1
AEC 4 2
AFC 5 2
AGC 6 2
AHC 7 3
AIC 8 3
AJC 9 3
;
data want;
set have;
if mod(order, 3) = 1 then new_order + 1;
run;
data have;
input Name $ ORDER;* NEW ORDER#;
cards;
ABC 1 1
ACC 2 1
ADC 3 1
AEC 4 2
AFC 5 2
AGC 6 2
AHC 7 3
AIC 8 3
AJC 9 3
;
data want;
set have;
if mod(order, 3) = 1 then new_order + 1;
run;
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!
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.