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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 1 reply
  • 589 views
  • 0 likes
  • 2 in conversation