Hi, all:
I have a variable name "formatted_value", I use ODS to export my SAS file into CSV format (Code shown below). However, it changed the number form after export. How to keep the oringinal format for "formatted_value"? The "formatted_value" in SAS is Charateric.
Thanks.
ods csv file="\\Libraries\Documents\Final2020.CSV";
proc print data=yt.final;
run;
ods csv close;
For example,
SAS formatted_value
17.0
8.0
100.0
After ODS export,
CSV formatted_value
17
8
100
Hi,
Can I check, how are you opening the .csv file which is created? Are you opening the file in Excel for example? If so then therein lies your problem. If you open the file in notepad you should see the data exactly as it is in the dataset, Excel has a lot of these "features" and its one of the top (of many) reason why not to use Excel.
If however your data appears in Notepad without it, then please post a small datastep example of the data you have, to go along with the export, so we can test it.
1. Specify the format in the procedure generating output:
proc print data=yt.final;
var myvariable;
format myvariable f5.1;
run;
2. Do not use Excel to look at the result, it is IGNORING the trailing 0.
Open the set in an actual text program such as Notepad. CSV contains NO Format information in the file so the reading program picks the appearance.
Or use a method that specifies appearance to Excel which would work which means a different ODS destination and methods vary depending on destination chosen.
I can't format the number, because I have other format shown below.
47989 |
680 |
31 |
681 |
187 |
5814 |
405 |
319 |
149 |
887 |
5100 |
4047 |
74 |
33 |
@ybz12003 wrote:
I can't format the number, because I have other format shown below.
47989 680 31 681 187 5814 405 319 149 887 5100 4047 74 33
Comment does not make sense when you said in the original post:
"
For example,
SAS formatted_value
17.0
8.0
100.0
"
So which is it?
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Lock in the best rate now before the price increases on April 1.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.