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!!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 290 views
  • 3 likes
  • 2 in conversation