Help using Base SAS procedures

create dynamic char Formats

Reply
N/A
Posts: 0

create dynamic char Formats

Hi friends

I have a problem may be some one could help me out
i have a Char Column and it has value like C090304, C090305 , H090304 , I090306
but I have to display
H090304 - Hold From 04/03
C090304 - Cancel on 04/03
I090306 - Issued on 06/03

Can i do it using proc format. or how can i achieve. I know i can do it easyly using data step and string functions ... but i don't want to create new column.

Regards
Avi
SAS Employee
Posts: 156

Re: create dynamic char Formats

This is one way of doing it....[pre]

data input(keep=CharColumn);
input CharColumn $;
datalines;
H090304
C090304
I090306
;
run;

proc format;
value $type
'H' = 'Hold from'
'C' = 'Cancel on'
'I' = 'Issued on';
run;

data _format(keep=fmtname start end label);
retain fmtname '$Display';
set input(rename=(CharColumn=start));
end=start;
label=put(substr(start,1,1),type.)!!' '!!substr(start,6,2)!!'/'!!substr(start,4,2);
run;

proc format cntlin=_format; run;

proc print data=input;
format CharColumn $display.;
run;[/pre]
N/A
Posts: 0

Re: create dynamic char Formats

hey Thanks Geniz
Ask a Question
Discussion stats
  • 2 replies
  • 62 views
  • 0 likes
  • 2 in conversation