LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (June 2006, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 20 Jun 2006 09:49:55 -0700
Reply-To:     chandu.isi@GMAIL.COM
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         chandu.isi@GMAIL.COM
Organization: http://groups.google.com
Subject:      Re: conversion between numeric and character using PUT and INPUT
Comments: To: sas-l@uga.edu
In-Reply-To:  <FqCdncfiBe1cvwXZ4p2dnA@telenor.com>
Content-Type: text/plain; charset="iso-8859-1"

Hi RR,

The date2 is already in numeric, so u don't require the input fun. in

> data two_b; > set two; > date1 = put(input(date2, date7.), mmddyy8.); /* error here, this variable > is empty */ > run;

So just use the PUT statement like below:

data two_b; set two; date1 = put(date2, mmddyy8.); /* Now no error here, this variable is of date1 format */ run;

I hope this will work.

Thanks and Regards, Chandu.

Rune Runnestø wrote: > /* > > I have two SAS data sets, ONE and TWO. Data set ONE contains a > variable called DATE1 which is a character in the form MM/DD/YY. > Data set TWO contains a character variable called DATE2 which is > in the form ddMONyy. Data set TWO also contains the variable HR > (heart rate). I want to Write a program to merge these data sets by date, > and assume that there are no duplicate dates in each of the > data sets. I suppose this problem can be solved in two ways: > > 1) Use the PUT function to create a new variable in one of the > data sets so that the two data sets have an identical > variable to use. > > 2) Use an INPUT function to create a real SAS date variable in > both data sets for merging. > > */ > > data one; > input > date1 $8. > height > weight > ; > datalines; > 10/21/46 58 155 > 09/05/55 66 220 > 01/11/44 63 205 > ; > > > data two; > input > date2 : date7. > hr > ; > * format date2 date7.; > datalines; > 21OCT46 58 > 11JAN44 68 > 05SEP55 72 > ; > > /* > > 1) Use the PUT function to create a new variable in one of the > data sets so that the two data sets have an identical > variable to use. > */ > data two_b; > set two; > date1 = put(input(date2, date7.), mmddyy8.); /* error here, this variable > is empty */ > run; > > proc sort data = one; > by date1; > run; > proc sort data = two_b; > by date1; > run; > data both; > merge one two_b; > by date1; > run; > > /* > > 2) Use an INPUT function to create a real SAS date variable in > both data sets for merging. > */ > data one_b; > set one; > date = input(date1, mmddyy8.); > run; > > data two_b; > set two; > date = input(date2, date7.); /* error here, this variable is empty */ > run; > > proc sort data = one_b; > by date; > run; > proc sort data = two_b; > by date; > run; > data both; > merge one_b two_b; > by date; > format date mmddyy8.; > run; > > /* > Can anyone tell me why the data set TWO_B is empty ? > > Regards > Rune > > */


Back to: Top of message | Previous page | Main SAS-L page