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

I am changing the current variable name of DOB (character) to BirthDt (numeric). The DOB variable is listed in DATE9. and I am trying to change it to MMDDYY10, but keep receiving an error. 

 

Here is my code:

 

DATA WORK.D;
SET Hyp.M( KEEP = SocSecNum Gender Eth Racial DOB
RENAME = ( SocSecNum = SSN
DOB = BirthDt));
LENGTH SSN $11
GenderCd 8
EthCd $1
RaceCd $1
EthRaceCd $3;

IF Gender = 'Male' THEN GenderCd = 1;
ELSE IF Gender = 'Female' THEN GenderCd = 2;


IF Eth = 'Hispanic or Latino' THEN EthCd = 'H';
ELSE IF Eth = 'Not Hispanic or Latino' THEN EthCd = 'N';

IF MISSING(Racial) = 1 THEN RaceCd = ' ';
ELSE IF Racial = 'Caucasian' THEN RaceCd = 'W';
ELSE IF Racial = 'African American' THEN RaceCd = 'B';
ELSE IF Racial = 'Other Race' THEN RaceCd = 'O';

IF Eth = 'Hispanic or Latino' THEN EthRaceCd = 'HIS';
ELSE IF Racial = 'African American' THEN EthRaceCd = 'NHB';
ELSE IF Racial = 'Caucasian' THEN EthRaceCd = 'NHW';
ELSE IF Racial = 'Other Race' THEN EthRaceCd = 'NHO';

BirthDt = INPUT(DOB, ANYDTDTE32.);
Format BirthDt MMDDYY10.;
RUN;

 

Screen Shot 2020-11-06 at 10.13.57 PM.png

 

Here is my log:

Screen Shot 2020-11-06 at 10.13.10 PM.png

Here's the first line of data I am working from:

Screen Shot 2020-11-06 at 10.15.13 PM.png

 the 22JAN1974 to 01/22/1974

I'm not sure what I am missing, I suspect my variable is still not converting from character to numeric, but thought that the INPUT statement would do that... any advice would be great, thanks in advance!

1 ACCEPTED SOLUTION
3 REPLIES 3

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 2164 views
  • 0 likes
  • 2 in conversation