BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
acordes
Rhodochrosite | Level 12

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;
1 ACCEPTED SOLUTION

Accepted Solutions
SASJedi
Ammonite | Level 13

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;

 

Check out my Jedi SAS Tricks for SAS Users

View solution in original post

2 REPLIES 2
SASJedi
Ammonite | Level 13

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;

 

Check out my Jedi SAS Tricks for SAS Users
Tom
Super User Tom
Super User

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?

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 827 views
  • 0 likes
  • 3 in conversation