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.
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.