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

I need to output the data to text file but the missing value must be converted to "." . I have tried to use option missing but it's the same (.) as null value, thus the output still blank instead of (.) . Please help. Thanks.

 

temp_data:

Model   Type   Month_1   Month_2   Month_3  Month_4

A   FIRE   123.4   5   56.7   23.86

B   FIRE   2349   35.3   .   .

C              234.8   .   .   .

 

text file:

A|FIRE|123.4|5|56.7|23.86

B|FIRE|2349|35.3|.|.

C||234.8|.|.|.

 

option missing = '.' ;

proc export data=temp_data

outfile="&path"

dbms=dlm replace;

putnames=no;

delimiter="|";

run;

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hello @irene_o and welcome to the SAS Support Communities!

 

The periods for numeric missing values (and the blanks for missing character values) are suppressed by the DSD option of the FILE statement in the DATA step code that PROC EXPORT generates. Write your own DATA step to take control over the options.

 

Example:

data _null_;
file "&path" dlm='|';
set temp_data;
put (_all_)(:);
run;

 

View solution in original post

4 REPLIES 4
FreelanceReinh
Jade | Level 19

Hello @irene_o and welcome to the SAS Support Communities!

 

The periods for numeric missing values (and the blanks for missing character values) are suppressed by the DSD option of the FILE statement in the DATA step code that PROC EXPORT generates. Write your own DATA step to take control over the options.

 

Example:

data _null_;
file "&path" dlm='|';
set temp_data;
put (_all_)(:);
run;

 

irene_o
Calcite | Level 5

The code works perfectly. Thanks!

Tom
Super User Tom
Super User

Why?  What is it that is going to read this file that does not understand that adjacent delimiters means the value is missing?

 

If you are writing a delimited file without a header line there is NO reason to use PROC EXPORT.  

It is easier to just write the data step to create the text file yourself. In which case you a tweak the code for whatever non-standard format your text file needs.

data _null_;
  set temp_data ;
  file "&path" dlm='|';
  put (_all_) (+0);
run;
irene_o
Calcite | Level 5

Thanks for the code! I was using Proc Report as I have another text output where null numeric is blank instead of period. Now I learn new thing using data step which is very useful.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 4 replies
  • 830 views
  • 2 likes
  • 3 in conversation