BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Banana19
Obsidian | Level 7

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

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;

View solution in original post

2 REPLIES 2
novinosrin
Tourmaline | Level 20

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;
Banana19
Obsidian | Level 7
It worked when i used the above logic. Thanks a bunch!!
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
  • 2 replies
  • 1027 views
  • 3 likes
  • 2 in conversation