BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Crystal_F
Quartz | Level 8

I encountered a technical issue when importing an Excel file into SAS. The original cell format in Excel was #,##0.00,,"M" (e.g., displaying values like 3.62M). However, upon importing the data into SAS, the format changed to NLMNY15., displaying the values as $3,617,180. I would appreciate any assistance in resolving this issue, as I aim to retain all decimal values and preserve the data as it was in its raw form. Thank you!

proc import datafile="/app/sas/users/datahave.xlsx"
    out=mockdata
    dbms=xlsx
    replace;
    getnames=yes;
run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

1) Save this excel as a CSV file and import it again as a string variable.

data want;
infile "C:\Users\xiakeshan\Documents\Downloads\mockdata.csv" dsd truncover firstobs=2;
input x : $40. April : $40.;
run;

Ksharp_0-1748395364215.png

 

 

2) Make a new format in sas and attach this dataset.

proc import datafile = "C:\Users\xiakeshan\Documents\Downloads\mockdata.xlsx" out =have replace dbms =excel ;
run;

proc format;
picture fmt(round)
low-high='000,000,000.99M'(mult=0.0001)
;
quit;
data want2;
set have;
format April_202X fmt.;
run;

Ksharp_1-1748395429444.png

 

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

Can't you just change the format that is attached to the variable so it prints differently?

 

Example:

proc print;
 format _numeric_;
run;

Tom_0-1748367136105.png

 

 

Ksharp
Super User

1) Save this excel as a CSV file and import it again as a string variable.

data want;
infile "C:\Users\xiakeshan\Documents\Downloads\mockdata.csv" dsd truncover firstobs=2;
input x : $40. April : $40.;
run;

Ksharp_0-1748395364215.png

 

 

2) Make a new format in sas and attach this dataset.

proc import datafile = "C:\Users\xiakeshan\Documents\Downloads\mockdata.xlsx" out =have replace dbms =excel ;
run;

proc format;
picture fmt(round)
low-high='000,000,000.99M'(mult=0.0001)
;
quit;
data want2;
set have;
format April_202X fmt.;
run;

Ksharp_1-1748395429444.png

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 618 views
  • 1 like
  • 3 in conversation