We have a SAS Data Set:
One
-----------------------------------------
Date_Info
-----------------------------------------
24Nov is Sunday
25Nov is Monday
26Nov is Tuesday
27Nov is Wednesday
28NOV IS THURSDAY
29nov is Friday
30NOV is SATURDAY
We need to create A SAS Data SET where only days should be in uppercase and rest should be in lowcase.
One
-------------------------------------------
Date_Info
-------------------------------------------
24nov is SUNDAY
25nov is MONDAY
26nov is TUESDAY
27nov is WEDNESDAY
28nov is THURSDAY
29nov is FRIDAY
30nov is SATURDAY
Now prepare your Base SAS and
Advance SAS Certification Exams with Online Mock tests: http://exam.sankhyana.com
For training related info kindly mail us at info@sankhyana.com
www.sankhyana.com
One
-----------------------------------------
Date_Info
-----------------------------------------
24Nov is Sunday
25Nov is Monday
26Nov is Tuesday
27Nov is Wednesday
28NOV IS THURSDAY
29nov is Friday
30NOV is SATURDAY
We need to create A SAS Data SET where only days should be in uppercase and rest should be in lowcase.
One
-------------------------------------------
Date_Info
-------------------------------------------
24nov is SUNDAY
25nov is MONDAY
26nov is TUESDAY
27nov is WEDNESDAY
28nov is THURSDAY
29nov is FRIDAY
30nov is SATURDAY
Now prepare your Base SAS and
Advance SAS Certification Exams with Online Mock tests: http://exam.sankhyana.com
For training related info kindly mail us at info@sankhyana.com
www.sankhyana.com
data one;
ReplyDeleteinfile datalines dsd;
length date_info $20;
input date_info ;
date_info=put(date_info,20.);
file print;
put date_info;
datalines;
24Nov is Sunday
25Nov is Monday
26Nov is Tuesday
27Nov is Wednesday
28NOV IS THURSDAy
29nov is Friday
30NOV is SATURDAY
;
run;
data _null_;
set one;
length date_info $ 20;
date_info=lowcase(date_info);
date_info=tranwrd(date_info,scan(date_info,-1,1),upcase(scan(date_info,-1,1)));
file print;
put date_info;
run;
data one;
ReplyDeleteinput text $20.;
cards;
4Nov is Sunday
25Nov is Monday
26Nov is Tuesday
27Nov is Wednesday
28NOV IS THURSDAY
29nov is Friday
30NOV is SATURDAY
;
run;
data two;
set one;
newText=catx('',lowcase(scan(text,1)),lowcase(scan(text,2)),upcase(scan(text,3)));
run;
data two(drop=text);
Deleteset one;
newText=catx('',lowcase(scan(text,1)),lowcase(scan(text,2)),upcase(scan(text,3)));
run;
proc print data=two label;
label newText='Date_info';
run;
data two(drop=date_info rename=date_info_1=date_info);
ReplyDeleteset one;
date_info_1=cats(lowcase(scan(date_info,1," ")) ,
" ",lowcase(scan(date_info,2," ")),
" ",upcase(scan(date_info,-1," ")));
run;
cats will remove the leading & trailing blks and concatenate them, instead catx with delimiter can be used or cat.
Deletedata one;
input date_info $20.;
cards;
24Nov is Sunday
25Nov is Monday
26Nov is Tuesday
27Nov is Wednesday
28NOV IS THURSDAY
29nov is Friday
30NOV is SATURDAY
;
run;
data two;
set one;
date_info=cat(lowcase(scan(date_info,1," ")) ,
" ",lowcase(scan(date_info,2," ")),
" ",upcase(scan(date_info,-1," ")));
run;
data x1;
ReplyDeletelength date_info $ 25;
input date_info & $;
datalines;
24Nov is Sunday
25Nov is Monday
26Nov is Tuesday
27Nov is Wednesday
28NOV IS THURSDAY
29nov is Friday
30NOV is SATURDAY
;
run;
data x3;
set x1;
date_info=tranwrd(date_info,substr(date_info,10),upcase(scan(date_info,3,' ')));
run;
data one;
ReplyDeleteinfile datalines ;
input name & $20.;
name2 = substr(name,1,9);
name1 = upcase(substr(name,10,10));
name3 = name2||name1 ;
name = compbl(name3);
drop name2 name1 name3;
datalines;
24Nov is Sunday
25Nov is Monday
26Nov is Tuesday
27Nov is Wednesday
28NOV IS THURSDAY
29nov is Friday
30NOV is SATURDAY
;
run;