BookmarkSubscribeRSS Feed
sarymay
Calcite | Level 5

I am having some trouble with SAS formats that I cannot figure out. I have two variables-- ptid2 and dob2. When I run a proc contents I am told that these variables have the following properties:

         

ptid2:     type=char     len=11     format=$11.      informat=$11.

dob2:     type=num     len=8       format=date9.   informat=date9

then I create a new data set from this data set that changes these variables in some cases. The code is as follows:

if ptid='00302333XX1' and inc_date2 lt 201005

     then do;

          ptid2='00305560440' and dob2=mdy(3,30,2010);

     end;

else if ptid='00302333XX1' and inc_date2 ge 201005

     then do;

          ptid2='00305560555' and dob2=mdy(5,23,2011);

when I run this code I am told that char values are being converted to numeric values at column 19 (where I am setting ptid='XXXXXXXXXXX' and numeric values are being converted to char values at column 33 (where I am setting dob2=mdy(mm,dd,yyyy).

Any thoughts on why this may be happening??

Thank you for your help!

2 REPLIES 2
Reeza
Super User

inc_date2 lt 201005

Check that line.

What format/type is inc_date2 and 201005 isn't a valid date to compare to, so what are you trying to check.

I'm assuming you haven't calculated the sas numeric date of something here...

Astounding
PROC Star

Your outcomes must be listed as separate statements.

if ... then do;

   ptid2='00305560440';

   dob2=mdy(3,30,2010);

end;

You may have problems with the comparison as well, as Reeza indicated.  It would help if you would post the similar PROC CONTENTS results for inc_date2.

Good luck.

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