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?
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.