Hello Experts,
partition_Path=/vcs_valuation_type=FRTB/vcs_run_subtype=ES/vcs_run_qualifier=FC/cob_year=2022/cob_month=03/cobdate=20220304/package_type=FLASH/resu
lt_type=FRTB_TRADERBOOK_PNL/result_request_id=5;
formatted_partition= vcs_valuation_type="FRTB",vcs_run_subtype="ES",vcs_run_qualifier="FC",cob_year=2022,cob_month=03,cobdate=20220304,package_type
i have written one simple program to get formatted_partition based on above requirement but with my program it also adding doble quote to digits value.
%let filePath=/vcs_valuation_type=FRTB/vcs_run_subtype=ES/vcs_run_qualifier=FC/cob_year=2022/cob_month=03/cobdate=20220304/package_type=FLASH/resu
lt_type=FRTB_TRADERBOOK_PNL/result_request_id=5;
data _null_;
temp=substr(tranwrd((tranwrd("&filePath",'/','",')),'=','="'),3);
form_path=compress(%sysfunc(cat(temp||'"')));
put form_path;
%let formPath=form_path;
run;
Try
data _null_;
length have want $ 500 pair $ 100 value $ 40;
have = symget('partition_path');
if first(have) = '/' then pp = substr(have, 2);
do i = 1 to countw(have, '/');
pair = scan(have, i, '/');
value = scan(pair, 2, '=');
want = catx(',', want, scan(pair, 1, '='));
if anyalpha(value) then do;
want = catx('=', want, quote(trim(value)));
end;
else do;
want = catx('=', want, value);
end;
end;
call symputx('formatted_path', want);
run;
Try
data _null_;
length have want $ 500 pair $ 100 value $ 40;
have = symget('partition_path');
if first(have) = '/' then pp = substr(have, 2);
do i = 1 to countw(have, '/');
pair = scan(have, i, '/');
value = scan(pair, 2, '=');
want = catx(',', want, scan(pair, 1, '='));
if anyalpha(value) then do;
want = catx('=', want, quote(trim(value)));
end;
else do;
want = catx('=', want, value);
end;
end;
call symputx('formatted_path', want);
run;
%let filePath=/vcs_valuation_type=FRTB/vcs_run_subtype=ES/vcs_run_qualifier=FC/cob_year=2022/cob_month=03/cobdate=20220304/package_type=FLASH/result_type=FRTB_TRADERBOOK_PNL/result_request_id=5;
data x;
have=symget('filePath');
want=prxchange('s/\//,/i',-1,have);
want=prxchange('s/^,+//i',-1,want);
want=prxchange('s/(?<==)([a-z_]+)/"\1"/i',-1,want);
put have= / want=;
run;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: