BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
CharlesFowler72
Obsidian | Level 7

Should be a simple one for someone but been stuck on this for a while now.

 

I'm using a proc report with an out function. All works fine except that with the output the columns are headed _C1_, _C2_...etc.

 

I just want them to stay as the headings in the proc report.

 

Labelling individually is not an option as they are months and will be showing the most recent 12 months and so changing every time. code used below, pretty simple stuff.  

 

proc report data = data (where=(

month > &year_Month

and month <= &current_Month))

out=test1;

columns sector month, exposure;

define sector/group;

define month/across;

define exposure/analysis sum format=comma14.;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Sums by month and sector are easily handled by PROC SUMMARY, giving you complete control over the naming of the variables. If it must be in some tabular form, then PROC TRANSPOSE will get you there.

--
Paige Miller

View solution in original post

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

I would tend to avoid using across.  Simply transpose your data before the proc report, that way you then have a nice dataset which you can QC.  The _c1_ is automatic variable labelling, depending on how you have your data - which you have not shown - a transpose will allow you to label and specify name of variables, e.g;

data have;
  id=1; lab="abc"; nam="VAR1"; val=1; output;
  id=1; lab="def rft"; nam="VAR2"; val=5; output;
run;

proc transpose data=have;
  by id;
  var val;
  id nam;
  idlabel lab;
run;

So nam variable will be name of variable, lab will contain the label for it.  You can then report the above quite simply with:

columns _all_;
PaigeMiller
Diamond | Level 26

Sums by month and sector are easily handled by PROC SUMMARY, giving you complete control over the naming of the variables. If it must be in some tabular form, then PROC TRANSPOSE will get you there.

--
Paige Miller

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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