SAS date in MMDDYY10.

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 7
Accepted Solution

SAS date in MMDDYY10.

When i display a date that is read from the input as MMDDYY10. or YYMMDD10. and then display it in the output, i get date in the correct format when there is a valid data in the input ( 2013-07-07 will be displayed as 07/07/2013).

But when there is no data, it is being displayed as '.' whereas i want it to be displayed as blank(spaces). Can someone help me out with this.


Accepted Solutions
Solution
‎07-17-2014 03:01 AM
Super Contributor
Posts: 297

Re: SAS date in MMDDYY10.

Posted in reply to AdarshSaukat

Hi Adarsh,

Missing numeric values are displayed using a period by default.  You can change this using the System Option Missing = " ", however this will apply to all numeric variables until you exit your session or change the option back to a period.

SAS(R) 9.2 Language Reference: Dictionary, Fourth Edition

Regards,

Scott

View solution in original post


All Replies
Solution
‎07-17-2014 03:01 AM
Super Contributor
Posts: 297

Re: SAS date in MMDDYY10.

Posted in reply to AdarshSaukat

Hi Adarsh,

Missing numeric values are displayed using a period by default.  You can change this using the System Option Missing = " ", however this will apply to all numeric variables until you exit your session or change the option back to a period.

SAS(R) 9.2 Language Reference: Dictionary, Fourth Edition

Regards,

Scott

Occasional Contributor
Posts: 7

Re: SAS date in MMDDYY10.

Posted in reply to Scott_Mitchell

This is used in a job that runs on a schedule. Will it still be possible to use this command?

Super Contributor
Posts: 297

Re: SAS date in MMDDYY10.

Posted in reply to AdarshSaukat

Yes, but the question is, why do you need it formatted in such a way?

Occasional Contributor
Posts: 7

Re: SAS date in MMDDYY10.

Posted in reply to Scott_Mitchell

The output of this file is used in a downstream application that does not recognise '.', but would be able to process the data as blanks.

Also in case the data is there, it has to be in MMDDYY10 format.

I tried reading the data in CHAR and then displaying spaces, but the date in the output (in case there is data) is shown in a double quotes. If there was a way to remove the quotes, that would suffice too.

Attached are the pictures.

Current output is the one that has the '.' in in, but the date in the correct way. (I am guessing that MMDDYY10 does not put quotes)

Current output.jpg

Character Output is the output where the spaces are present, but the date is enclosed in quotes.

Char output.jpg

Super User
Super User
Posts: 7,942

Re: SAS date in MMDDYY10.

Posted in reply to AdarshSaukat

Hi,

Convert the date to text, then it would be easier, you don't know what other effect setting missing would do - depends on the rest of the program.

text_date=tranwrd(put(date,mmddyy10.),"."," ");

Then use text_date.

Super User
Posts: 7,758

Re: SAS date in MMDDYY10.

Posted in reply to AdarshSaukat

You probably have the dsd option specified. If none of your character data contain the delimiter ',', you can omit this, and will have no quotes around the strings.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Valued Guide
Posts: 2,177

Re: SAS date in MMDDYY10.

Posted in reply to KurtBremser

Kurt

the DSD infile option does not cause blanks to be quoted; Try the following code

It quotes only where needed

data _null_ ;

retain a 'ertyu' blank ' ' value 1234 c 12345.67 d "&sysdate"d ;

format c commax12.1 d worddate. ;

file log dsd ;

put (_all_)(Smiley Happy;

run ;

In the log

ertyu,,1234,"12.345,7","July 17, 2014"

NOTE: DATA statement use


Valued Guide
Posts: 2,177

Re: SAS date in MMDDYY10.

Posted in reply to AdarshSaukat

the quotes around a blank value are provided by the routine you use to create the CSV file.

I agree with you that that is poor

However, I believe that, quoting a blank as it is written, is "normal" behavior of the ods csv destination and one effect of applying the $quote. format to all character variables. There are also other ways that generate those quoted blanks.

SAS has simple code which would not quote blanks while ensuring a valid, readable csv file is created.

Super User
Posts: 7,758

Re: SAS date in MMDDYY10.

Posted in reply to AdarshSaukat

In a batch job, options missing will only be effective for the current job.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 7

Re: SAS date in MMDDYY10.

Posted in reply to Scott_Mitchell

Hi Scott,

The below option before the display seems to work fine, and is being displayed for all the scheduled job runs.

OPTIONS MISSING=' ';

I am getting the output in the required format.

Thanks all for helping me out. Smiley Happy

Super User
Posts: 7,758

Re: SAS date in MMDDYY10.

Posted in reply to AdarshSaukat

You can achieve what you want in several ways. One is to use options missing = " ", as already indicated. Another is to create a display variable depending on the value:

length disp_date $10;

if date = .

then disp_date = " ";

else disp_date = put(date,mmddyy10.);

and then use disp_date in the output. This helps if you want other missing numeric values to display as "." and can therefore not use the "options missing".

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Valued Guide
Posts: 2,177

Re: SAS date in MMDDYY10.

Posted in reply to KurtBremser

to affect all jobs place in config file

-MISSING " "

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 12 replies
  • 497 views
  • 3 likes
  • 5 in conversation