BookmarkSubscribeRSS Feed
baroche64
Fluorite | Level 6

Please what is the PROC REPORT equivalent to specifying a common format for multiple variables using a single statement for efficiency?

in PROC PRINT I would do the following:

format NumberofFarms TotalLivestock Average_Livestock_Size &TopLivestock1._Farms  &TopLivestock2._Farms  &TopLivestock3._Farms  &TopLivestock4._Farms &TopLivestock5._Farms 
&TopLivestock1._Livestock_Size &TopLivestock2._Livestock_Size &TopLivestock3._Livestock_Size &TopLivestock4._Livestock_Size &TopLivestock5._Livestock_Size Comma20.;

For PROC REPORT using the DEFINE statement does not work for multiple variables i.e:

DEFINE NumberofFarms TotalLivestock / format=comma20.;

Please is there a more efficient way to assign formats to multiple variables in a single statement when using PROC REPORT?

 

 

2 REPLIES 2
Kurt_Bremser
Super User

Just use the format statement as in PROC PRINT:

proc report data=sashelp.class;
column sex height weight;
format height weight 20.7;
define sex / group;
define height / display;
define weight / display;
run;
BrunoMueller
SAS Super FREQ

You can use variable lists in the define statement, see the example below. The variable lists specified are based on the variable in the input data set not how variables are listed in the column statement.

See here for a doc on variable list: https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lrcon/p0wphcpsfgx6o7n1sjtqzizp1n39.htm

 

proc contents data=sashelp.cars order=varnum short;
run;

proc report data=sashelp.cars(obs=30);
  column Make Model Type EngineSize Cylinders Horsepower MPG_City MPG_Highway Weight Wheelbase Length;
  define make -- type / display style={background=lightyellow};
  define mpg_: / analysis sum format=z12.2 style={background=lightblue};
run;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 2 replies
  • 439 views
  • 3 likes
  • 3 in conversation