BookmarkSubscribeRSS Feed
natrajpranita
Calcite | Level 5

data class;
set sashelp.class;
run;

PROC SQL;
SELECT
DISTINCT COUNT(*) + 1 INTO :CNT1
FROM class;
Quit;

ods _all_ close;
ods Excel file="/&path/class.xlsx"
STYLE= sasdocprinter
options(sheet_name='class'
Orientation= "landscape"
Absolute_Column_Width="20"
Frozen_headers= 'yes'
embedded_titles='yes'
embedded_footnotes='yes'
);
proc report data=class;
compute after _page_/ style={just=left};
line @1 "T &CNT1";
endcomp;
run;
ods excel close;
title;
footnote;

 

On executing the above code I get the excel sheet as shown in the attachment.

 

If you check the last row i.e. row number 21, I get the "T    20" in the same cell that extends up to column E. But I want the "T" to be in cell "A21" and "20" in cell "B21".

 

Requesting your help to achieve the above.

 

Thanks.

Pranita

 

1 REPLY 1
ballardw
Super User

If you want specific values in cells you're going to need to change your approach.

If you look you will see that the entire row for line 21 has columns A through E MERGED. You can check the property in Excel if you doubt that.

 

So LINE is not what you want to use.

Since you have no other column or define statements it hard to tell what your real use case may be but you likely want two columns computed in your compute after

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 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

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