proc sort data=delq_array;
by application app_month perf_month;
run;
data want;
set delq_array ;
by application app_month perf_month;
length string $60;
retain string;
string=compress(catx('',string,delq));
if last.application then do;
output;
call missing(string);
end;
run;
the aove program currently appends delq column data and outputs based on last.application. But i need to append '.' if there is missing performance based on perf_month column by application.
indata is attached. please help me on the logic
current output
Application | App_month | Perf_month | string |
1 | 1-Sep-15 | 1-Sep-17 | 000112345211000000000000 |
2 | 1-Sep-15 | 1-Jul-17 | 0001123452000000000 |
3 | 1-Sep-15 | 1-Jan-16 |
00
|
required output
Application | App_month | Perf_month | string |
1 | 1-Sep-15 | 1-Sep-17 | 000112345211000000000000 |
2 | 1-Sep-15 | 1-Jul-17 | 0001123452..0.00000000 |
3 | 1-Sep-15 | 1-Jan-16 | .0.0 |
One possibility:
data want;
set delq_array ;
by application app_month perf_month;
length string $60;
retain string;
if first.application then do;
location=1;
string = repeat('.', 59);
end;
else location + month_diff;
substr(string, location, 1) = put(delq, 1.);
if last.application;
run;
This assumes that DELQ is numeric. If it is actually character with a length of $1, the program becomes simpler:
substr(string, location, 1) = delq;
@Astounding Good approach. I simplifier your code and trim out all extra dots based on Month_Diff to make output as similar as post
data want;
set delq_array ;
by application app_month perf_month;
length string $60;
retain string;
if first.application then string = repeat('.', 60);
substr(string,Month_Diff,1) = strip(put(delq,best.));
if last.application then do;
string = substr(string,1,Month_Diff);
output;
end;
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.