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

I have the following data:

 

SEDOLDateTNUMTVOLDVOLrelday
42960982002-06-15.10.92-54
42960982002-06-28...-41
42960982002-07-11.0.330.35-28
42960982002-07-15.0.330.35-24
42960982002-08-08.0.930.720
42960982002-08-08.117
42960982002-08-150.330.550.6515
42960982002-08-30...35
42960982002-10-040.90.880.8254
42960982002-11-27...67
42960982003-02-020.71172

 

I want the following:

 

SEDOLTNUMTVOLDVOLMonth
4296098.10.92-2
4296098.0.660.7-1
4296098.0.930.720
42960980.330.550.651
42960980.90.880.822
42960980.7113

 

Thanks in advance for your help.

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

Define a value format with a range and use that:

proc format lib=work;
value relday
  -60 -< -30 = -2
  -30 -< 0 = -1
  0 = 0
  0 <- 30 = 1
  30 <- 60 = 2
  other = .
;
run;

data test;
input x;
y = input(put(x,relday.),best.);
cards;
-61
-60
-35
-30
-15
0
1
30
60
65
;
run;

View solution in original post

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

I don't follow, please be more specific about how the logic in your desired result.

bd_user_10
Quartz | Level 8

Basically, this is what I need:

 

sum TNUM, TVOL and DVOL for the following period

 

if relday -60 to -30 then month is -2

if relday -30 to -1 is month is -1

if relday 0 then month is 0

if relday 1 to 30 then month is 1

if relday 30 to 60 then month is 2

 

I have many sedol, and I want to do the same for all. I hope this make sense.

Kurt_Bremser
Super User

Define a value format with a range and use that:

proc format lib=work;
value relday
  -60 -< -30 = -2
  -30 -< 0 = -1
  0 = 0
  0 <- 30 = 1
  30 <- 60 = 2
  other = .
;
run;

data test;
input x;
y = input(put(x,relday.),best.);
cards;
-61
-60
-35
-30
-15
0
1
30
60
65
;
run;
ballardw
Super User

Or perhaps you could provide the actual date you are comparing. Use of INTCK function should provide the result directly.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 852 views
  • 1 like
  • 4 in conversation