I am using Proc Report with an ACROSS variable to create a new dataset in the OUT= option. However, the variables in the new dataset that were created by the across variable do not have meaninful names.
How can I make the new variable names = the value of the ACROSS variable?
PROC REPORT DATA = INITIAL_DATANOWD OUT=NEW_DATA;
COLUMN ID MONTH,BALANCE;
DEFINE ID /GROUP ;
DEFINE MONTH /ACROSS ;
DEFINE BALANCE /SUM;
New_data has variables:
Name = "_C2_", Label = MONTH
Name = "_C3_", Label = MONTH
Name = "_C4_", Label = MONTH
Whereas I want New_data to have variables:
Name = "JAN"
Name = "FEB"
Name = "MAR"
Have you considered PROC TRANSPOSE (using ID and IDLABEL statements) after using PROC SUMMARY, instead?
I do know of a SAS format MONNAME3. which will display the three-character Month abbreviation, when referencing a SAS DATE type (numeric) variable. Not sure if it would be suitable for your PROC REPORT code though.
As Scott suggests, if all you need is an output dataset, you may want to use different techniques. If you want to stick with a PROC REPORT technique, however, then your choice is to use the RENAME= option on the OUT= specification, as shown in the code below.
PROC REPORT assigns absolute column numbers and only absolute column numbers to the variables it creates from ACROSS variable values -- so, you have to control the names if you do not want the absolute column numbers.
proc report data=sashelp.shoes nowd
out=work.shoeout(rename=(_c2_=Asia _c3_=Canada _c4_=Pacific));
where region in ('Asia', 'Canada', 'Pacific');
column product region,sales;
define product / group;
define region / across;