BookmarkSubscribeRSS Feed
VicSAS
Calcite | Level 5
I have a dataset with columns: code, name, a, b, c, aa, bb, cc.
I want to format the dataset to following format & export to excel, what's the best way to do it?

code, name, a, aa, aaa, b, bb, bbb, c, cc, ccc

note: aaa is a calculated field aaa=a/aa, bbb, ccc are the same.

Thanks!
1 REPLY 1
Cynthia_sas
Diamond | Level 26
Hi:
I'd use PROC REPORT and/or ODS CSV or ODS TAGSETS.EXCELXP or ODS HTML.

Consider the following code:
[pre]
ods csv file='myfile1.csv' ;
ods msoffice2k file='myfile2.xls' style=sasweb;
ods tagsets.excelxp file='myfile3.xls' style=sasweb;
proc report data=sashelp.class nowd;
column name age projage height projht;
define name / order;
define age / display;
define projage / computed;
define height /display;
define projht / computed;
compute projage;
** age in 5 years;
projage = age + 5;
endcomp;
compute projht;
** height at 1.25 of current height;
projht = height * 1.25;
endcomp;
run;
ods _all_ close;
[/pre]

If you need more help with PROC REPORT or deciding which one of the ODS destinations is right for your needs, you might consider contacting Tech Support.

cynthia

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 1 reply
  • 857 views
  • 0 likes
  • 2 in conversation