data Karen_D2t1; set sashelp.cars; run; proc sort data=Karen_D2t1; by make type; run; proc means data=Karen_D2t1 mean; by make type; var horsepower; output out=a2(drop=_freq_ _type_) mean=MeanHP; run; proc means data=Karen_D2t1 mean; by make type; var invoice ; output out=a3(drop=_freq_ _type_) mean=MeanIN; run; proc means data=Karen_D2t1 mean; by make type; var weight; output out=a4(drop=_freq_ _type_) mean=MeanW; run; data a5; merge a2 a3 a4; run; proc transpose data=a5 out=a5t; var MeanHP; run; data a8; Length char1 $ 1500.; set a5t; char1=catx(", ", of col1-col29); run;
Hello. I Have i code below,in which i treied to create variable "char1" which will contain values of all variables from dataset a5t,separated by "," . And this works but i just need to get more flexible code which will work for any count of columns and not only 29 of them. Can you help me to find a solution? Would be thankful!
Thank you for providing fully working sample code. That always helps a lot.
Just by looking at your code without even trying to understand what you want to achieve: It feels very much like there should be a simpler more direct way.
But to answer your actual question: Use the column modifier and the code will pick-up all variables that start with name col.
Thank you for providing fully working sample code. That always helps a lot.
Just by looking at your code without even trying to understand what you want to achieve: It feels very much like there should be a simpler more direct way.
But to answer your actual question: Use the column modifier and the code will pick-up all variables that start with name col.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.