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) 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;
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;
Can't you just change the format that is attached to the variable so it prints differently?
Example:
proc print;
format _numeric_;
run;
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;
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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.