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;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: