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

I have following tables.

 

data Table1;
  input product $ start_date :date7. end_date:date7. Price;
 format start_date end_date date9.;
  datalines;
p1 01Jan17 18Jan18 15
p1 19Jan18 15Jul18 30
p1 16Jul18 31Mar19 24
p2 08Jan17 31Dec17 17
p2 01Jan18 15Mar18 19
p2 26Jul18 31Mar19 18
;
Productsdedprice
p101-Jan-1718-Jan-1815
p119-Jan-1815-Jul-1830
p116-Jul-1831-Mar-1924
p208-Jan-1731-Dec-1717
p201-Jan-1815-Mar-1819
p226-Jul-1831-Mar-1918

 

I wanted to rank product, means p1 is rank 1 and p2 is rank 2.

 

ProductsdedpriceRank
p101-Jan-1718-Jan-18151
p119-Jan-1815-Jul-18301
p116-Jul-1831-Mar-19241
p208-Jan-1731-Dec-17172
p201-Jan-1815-Mar-18192
p226-Jul-1831-Mar-19182
1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20
data want;
    set Table1;
    by product;
    if first.product then Rank+1;
run;

View solution in original post

1 REPLY 1
PeterClemmensen
Tourmaline | Level 20
data want;
    set Table1;
    by product;
    if first.product then Rank+1;
run;
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
  • 1 reply
  • 667 views
  • 0 likes
  • 2 in conversation