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

Hello Folks

 

I am a long time reader first time Poster.

I'm a beginner in SAS with no programming/coding background. Currently stuck with a school assignment wherein i have to replace a missing date values in a Column (with existing mmddyy10. format)_with a given date 01/20/2001(mmddyy10.).

i used the following code 


proc format;
value ndate
. = 01/20/2001;
RUN;

proc print data=pipe_2 (obs=20);
FORMAT deactdt ndate.;
RUN;

 

It replaces the missing date values with 01/20/2001, but some how the existing date values in the column converted to actual sas date values.

 

how do i retain those existing date values in their initial assigned format which is MMDDYY10 AND ALSO KEEP THE NEWW REPLACED VALUES TO MMDDYY10.

 

YOUR response will be appreciated.

 

thanks

Have a wonderful day.

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

It's not clear whether you are pursuing the proper path or not.  A format changes what prints, but doesn't change the data values themselves.  If changing the data values is the goal, you could try:

 

data pipe_3;

set pipe_2;

if deactdt = . then deactdt = '20jan2001'd;

run;

 

You could print that data set as is, since any format applied to DEACTDT would remain unchanged.

 

To get your original format attempt to work, you could try:

 

proc format;

value ndate

. = '01/20/2001'

other = [mmddyyS10.];

run;

 

I can't test this until Monday, but that should work.  Note that the S in the format name indicates that the separator between parts of the date should be a slash.  (There are alternatives.)

View solution in original post

3 REPLIES 3
andreas_lds
Jade | Level 19
Can you post the log?
Astounding
PROC Star

It's not clear whether you are pursuing the proper path or not.  A format changes what prints, but doesn't change the data values themselves.  If changing the data values is the goal, you could try:

 

data pipe_3;

set pipe_2;

if deactdt = . then deactdt = '20jan2001'd;

run;

 

You could print that data set as is, since any format applied to DEACTDT would remain unchanged.

 

To get your original format attempt to work, you could try:

 

proc format;

value ndate

. = '01/20/2001'

other = [mmddyyS10.];

run;

 

I can't test this until Monday, but that should work.  Note that the S in the format name indicates that the separator between parts of the date should be a slash.  (There are alternatives.)

Azhar_ca
Calcite | Level 5
astounding data step fixed my problem.

thanks a lot.
Have A Wonderful Day.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 4672 views
  • 0 likes
  • 3 in conversation