BookmarkSubscribeRSS Feed
ddeb
Calcite | Level 5
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;
RUN;

New_data has variables:
Name = "_C2_", Label = MONTH
Name = "_C3_", Label = MONTH
Name = "_C4_", Label = MONTH
...Etc


Whereas I want New_data to have variables:
Name = "JAN"
Name = "FEB"
Name = "MAR"
2 REPLIES 2
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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.

Scott Barry
SBBWorks, Inc.
Cynthia_sas
Diamond | Level 26
Hi:
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.

cynthia
[pre]
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;
define sales/sum;
run;

ods listing;
proc print data=shoeout;
run;
[/pre]
What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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