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
SAS Super FREQ
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]

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

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
  • 723 views
  • 0 likes
  • 3 in conversation