I am formatting data using proc tabulate for when I call the data in proc report. I need to know the name of the columns from proc tabulate to reference them in proc report. This works until I add in the sum feature in proc tabulate. I’m not sure what my variable is called after I add in the sum feature. In this particular scenario the summed variable is students_enrolled_sum. However if I change out the location column with a marco &columnName identifying the column name gets tricky. Without the sum my column name is always n. I tried using labels however the label appears to only be a label and not a name as can be seen in a proc print statement like the print screen.
proc tabulate data=enrollment missing out=enrollment4 FORMAT=COMMA8.;
class location academic_period;
table sum*location='n'*students_enrolled='' sum*students_enrolled=' '*all, academic_period /row=float;
keylabel sum=' ' n=' ';
proc print data=enrollment4;
Can you not query the SASHELP.VCOLUMN (DICTIONARY.COLUMNS) information, if _sum is always the suffix then:
where LIBNAME="WORK" and MEMNAME="ABC";
Then use the macro variable. If _sum isn't the suffix always, take a list of your variables before and after and remove the before from the after to be left with additional variables.
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.