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;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.