BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
amritasingh
Calcite | Level 5

Hi,

 

I have some numeric data that has more than 16 significant decimal places. So I read them in as character variables and am using ODS Excel with Proc Print to write out a report. The character variables print fine in the listing with all the significant decimals. However in the excel output file they get converted to numeric and get rounded. Is there any way to avoid that and print out the full number as text in the Excel file?

 

Code:

data rpt;
infile in dsd dlm=',' truncover firstobs=2;
input
    minscore      :$char25.
    maxscore     :$char25.
;

 

ODS excel FILE="\\mcksas4\amrita\Files\Model Segment Counts.xlsx"  STYLE=excel;

proc print data=rpt noobs;
var minscore maxscore;
format minscore maxscore $25.;
ods excel close;

 

Sample input data:

Minscore                              Maxscore 

0.2750573833205815          0.3476960152906469

 

Proc print output in listing:

Minimum Score                    Maximum Score

0.2750573833205815          0.3476960152906469

 

Proc print output in Excel file:

Minimum Score                 Maximum Score
0.275057383                    0.347696015

 

Thank you,

Amrita

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

Below should work. Based on here.

ODS excel FILE="\\mcksas4\amrita\Files\Model Segment Counts.xlsx"  STYLE=excel;

proc print data=rpt noobs;
  var minscore / style(data)={tagattr="type:String"};
  var maxscore / style(data)={tagattr="type:String"};
run;

ods excel close;

View solution in original post

2 REPLIES 2
Patrick
Opal | Level 21

Below should work. Based on here.

ODS excel FILE="\\mcksas4\amrita\Files\Model Segment Counts.xlsx"  STYLE=excel;

proc print data=rpt noobs;
  var minscore / style(data)={tagattr="type:String"};
  var maxscore / style(data)={tagattr="type:String"};
run;

ods excel close;
amritasingh
Calcite | Level 5
Thank you so much Patrick!!! This worked perfectly!! It's much appreciated!
Amrita

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
  • 687 views
  • 1 like
  • 2 in conversation