Hi,
Ex:- In one variable i have like this
Input DEVELOPING COUNTRY INDIA i want it like this 'Developing Country INDIA'
Input DEVELOPING COUNTRY RUSSIA i want it like this 'Developing Country RUSSIA'
Like this I have 2000 records...
Thanks
is it always the last word that needs to stay capitalised?
Yes
Hi,
Try this...
data have;
input name $ 30.;
var_New=propcase(substr(name,1,19))||upcase(scan(name,3));
cards;
DEVELOPING COUNTRY INDIA
DEVELOPING COUNTRY RUSSIA
DEVELOPING COUNTRY CANADA
DEVELOPING COUNTRY china
;
run;
Thanks,
Shiva
Thanks Shiva But is there any code for selecting 'Words' ?
Because if i given 1, 19...If below the record has less characters...
How about something like:
data have;
length name var_new $30;
input name &;
do _n_=1 to countw(name)-1;
var_New=catx(" ",var_New,propcase(scan(name,_n_)));
end;
var_New=catx(" ",var_New,upcase(scan(name,_n_)));
cards;
DEVELOPING COUNTRY INDIA
DEVELOPING COUNTRY RUSSIA
DEVELOPING COUNTRY CANADA
DEVELOPING COUNTRY china
;
run;
Hi Art..
Great logic..it is working perfectly.
I want to know one more logic(Actually it is not my requirement but i am curious to get the logic)...
If i want to display "DEVELOPING" word as "DeVeLoPiNg" ..how can we change the above logic..
(Please Don't mind if i am asking useless question:-))..
Regards..
sanjeev.K
: You can manipulate data with whatever functions and logic are needed and available. E.g., while I'm not sure exactly which parts you are trying to change, but the following should give you a clue as to some of the possibilities:
\
data have (drop=j alternate);
length name var_new alternate alternate_New $30;
input name &;
do _n_=1 to countw(name)-1;
var_New=catx(" ",var_New,propcase(scan(name,_n_)));
alternate=upcase(scan(name,_n_));
do j=2 to length(scan(name,_n_)) by 2;
substr(alternate,j,1)=lowcase(substr(alternate,j,1));
end;
alternate_New=catx(" ",alternate_New,alternate);
end;
var_New=catx(" ",var_New,upcase(scan(name,_n_)));
alternate_New=catx(" ",alternate_New,upcase(scan(name,_n_)));
cards;
DEVELOPING COUNTRY INDIA
DEVELOPING COUNTRY RUSSIA
DEVELOPING COUNTRY CANADA
DEVELOPING COUNTRY china
;
run;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.