transfer character variable to numeric variable( date)

transfer character variable to numeric variable( date)

Post by Mind » Sat, 15 Apr 2006 09:10:22


Hey, guys,

I have a question regarding how to transfer a character variable to SAS
date variable.

The detail is I have a SAS data set TRY, which including a character
variable A such as "20050231", how can I transfer A to numeric
variable, which correspondences to Feb31, 2005. The reason of doing
this transfer is that I need to calculate the difference of this
variable with another date variable.

I try to use realdate=input(c_date, yymmdd8.); , but get error message.

Thanks a lot !

Mindy
 
 
 

transfer character variable to numeric variable( date)

Post by tobydun » Sat, 15 Apr 2006 10:44:14

Mindy ,

Your code is fine just supply a valid date and you should be fine.



Toby Dunn





From: Mindy < XXXX@XXXXX.COM >
Reply-To: Mindy < XXXX@XXXXX.COM >
To: XXXX@XXXXX.COM
Subject: transfer character variable to numeric variable( date)
Date: Thu, 13 Apr 2006 17:10:22 -0700

Hey, guys,

I have a question regarding how to transfer a character variable to SAS
date variable.

The detail is I have a SAS data set TRY, which including a character
variable A such as "20050231", how can I transfer A to numeric
variable, which correspondences to Feb31, 2005. The reason of doing
this transfer is that I need to calculate the difference of this
variable with another date variable.

I try to use realdate=input(c_date, yymmdd8.); , but get error message.

Thanks a lot !

Mindy

 
 
 

transfer character variable to numeric variable( date)

Post by tobydun » Sat, 15 Apr 2006 22:52:56

Glad you brought this up its way over due as a topic. and before we get
started just remember I am not after you.


Yes I have been there and I refuse to propogate stupid managers ideas. I
feel they are either inept and/or lazy at their job. You and others may
feel differently but hey we are all entitled to our own opinions.


Done right???? Well maybe done wrongly but achieving a correct result.

Okay perhaps its time for me to ge on my little soap box. There are only a
very small set of circumstanses where I can imagine an all macro shop being
of value. However, one would have to hire a team of macro experts and they
would have to awsome at macro syntax and design. As well as total eliminate
global macro variables from their programs (dispite what others would say
this can be done). Since I have only seen a handful of programmers who are
really good at design I doubt this is a feasable option.

And I have worked in as many shops as I have fields. One of which used
macro almost exclusively. There whole set up was shotty and held together
by ducktape and chewing gum. The funniest thing was my exwife bought me a
big pack of chewing gum and a few rolls of duck tape one day to put on my
computer at work as a joke. But in all honesty their all macro concept
sucked. But they kept on using them because that was how things were done
for consistency and correctness. After we had our parting of ways, I went
to work for their largest client. Who was looking to replace them, asap,
because they couldnt produce correct results fast enough. Seems that the
all macro idea failed. I have heard a few other places that tried the same
thing and they eventually failed with this approach and I know many shops
out there still try this concept. I rarely suffer these managers and
programmers that due this and I refuse to work with or for them for very
long. I am doing my Don Quixote impression tring to get people to
understand macros, macro design, and how to use them properly. Perhaps I am
just tilting at the ye o'l %macro and %mend statements but its a fight I can
atleast live with. I do practice what I preach, after I finish with the
suite of programs I am revamping now I will rework an all macro sas/internet
suite of programs. As I was testing the logic of the code it was amazing
that I used only a handful of macro variables and 1/10th SAS code (no macros
just a few macro vars) and could achieve the same results. The whole thing
looked, read, worked better and was so easy to change and fix that it would
make one cry.

O well its more than time for this rant to be over and thank you for
indulging me.

Toby Dunn