I want the newly created variable "combi" to hold the complete string, but it cuts off at length 8.
proc cas;
session mysession;
simple.topk /
inputs={"from_gama_agg", "combi"}, topk=5 bottomk=0 aggregator="n"
table={
name="LONGDRIVE_TS", CASLIB="onair"
where="_FECFACTU=_FULTPATA",
computedVars={{name="combi", format='$char44.'}},
computedVarsProgram="combi=ifc(modsermt in ('D1' 'D2'), 'Mto & desgaste', 'Mto')",
groupBy={"from_brand"}};
run;
quit;
This can be fixed by adding a LENGTH statement to your COMPUTEDVARSPROGRAM, something like this:
proc cas;
session mysession;
simple.topk /
inputs={"from_gama_agg", "combi"}, topk=5 bottomk=0 aggregator="n"
table={
name="LONGDRIVE_TS", CASLIB="onair"
where="_FECFACTU=_FULTPATA",
computedVars={{name="combi", format='$char44.'}},
computedVarsProgram="length combi varchar(44); combi=ifc(modsermt in ('D1' 'D2'), 'Mto & desgaste', 'Mto')",
groupBy={"from_brand"}};
run;
quit;
This can be fixed by adding a LENGTH statement to your COMPUTEDVARSPROGRAM, something like this:
proc cas;
session mysession;
simple.topk /
inputs={"from_gama_agg", "combi"}, topk=5 bottomk=0 aggregator="n"
table={
name="LONGDRIVE_TS", CASLIB="onair"
where="_FECFACTU=_FULTPATA",
computedVars={{name="combi", format='$char44.'}},
computedVarsProgram="length combi varchar(44); combi=ifc(modsermt in ('D1' 'D2'), 'Mto & desgaste', 'Mto')",
groupBy={"from_brand"}};
run;
quit;
Is there some reason you attached the $CHAR format to the variable? Does it have leading spaces that you want SAS to preserve when it prints the values?
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.