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;
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;
You want the actual text value "month" to become "monthly" and so on, correct?
Yes, that is correct
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.
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;
Hi,
The solution is not working...
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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.