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

Hi, I need help in changing transaction_type column values, example( Month to Monthly, year to yearly and quarterly)

 

data HAVE;
input policy_no $ transaction_type dt :date9.;
format dt date9.;
cards;
1     month        21MAY2018
1     year         22DEC2018
2     month        01JAN2019
3     Year         21MAY2017
3     quarter      05JUN2020
;

data want;
set have;
by policy_no dt; /* dt included here to force correct sort order */
if last.policy_no;
run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

Do something like this

 

data HAVE;
input policy_no $ transaction_type $ 7-16 dt :date9.;
format dt date9.;
cards;
1     month        21MAY2018
1     year         22DEC2018
2     month        01JAN2019
3     Year         21MAY2017
3     quarter      05JUN2020
;

data want;
   set have;
   if Propcase(transaction_type) = 'Month' then transaction_type = 'Monthly';
   else if Propcase(transaction_type) = 'Year' then transaction_type = 'Yearly';
   else if Propcase(transaction_type) = 'Quarter' then transaction_type = 'Quarterly';
run;

View solution in original post

8 REPLIES 8
PeterClemmensen
Tourmaline | Level 20

You want the actual text value "month" to become "monthly" and so on, correct?

Solly7
Pyrite | Level 9

Yes, that is correct

Amir
PROC Star

Hi @Solly7 ,

 

Are you looking for something like the following?

 

transaction_type = cats(transaction_type,'ly');

 

 

Does transaction_type ever have the value "Day"?

 

 

Kind regards,

Amir.

PeterClemmensen
Tourmaline | Level 20

Do something like this

 

data HAVE;
input policy_no $ transaction_type $ 7-16 dt :date9.;
format dt date9.;
cards;
1     month        21MAY2018
1     year         22DEC2018
2     month        01JAN2019
3     Year         21MAY2017
3     quarter      05JUN2020
;

data want;
   set have;
   if Propcase(transaction_type) = 'Month' then transaction_type = 'Monthly';
   else if Propcase(transaction_type) = 'Year' then transaction_type = 'Yearly';
   else if Propcase(transaction_type) = 'Quarter' then transaction_type = 'Quarterly';
run;
Solly7
Pyrite | Level 9

Hi,

 

The solution is not working...

Solly7
Pyrite | Level 9
Hi It worked now, i just had to format the transaction_type column
andreas_lds
Jade | Level 19

You have to take care that the variable is long enough to store the new values. If you want the new text in a report only, using a format seems to be the better option.

 

Solly7
Pyrite | Level 9
Oh okay, maybe is this why the above solution is not working from my side

Catch up on SAS Innovate 2026

Dive into keynotes, announcements and breakthroughs on demand.

Explore 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
  • 8 replies
  • 3520 views
  • 0 likes
  • 4 in conversation