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 (August 2000, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 8 Aug 2000 09:39:31 EDT
Reply-To:     Bernard Tremblay <imaginasys@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Bernard Tremblay <imaginasys@HOTMAIL.COM>
Subject:      Re: Should be an easy one: Informats etc.
Comments: To: Mark.K.Moran@CCMAIL.CENSUS.GOV
Content-Type: text/plain; charset=iso-8859-1; format=flowed

Marc, Very sorry for your grandmother. It's very sad.

I would like to solve some of those mysteries for you. Whenever you want to convert a numeric in character, you should specify the format unless you are knowing what's going to happen ... Since indcat must be formatted, SAS is using a best12. format and you have more than 3 spaces in front of the number wich explain why you don't get anything in the last 3 position of Var13 ... Mystery 1 solved.

Since you scanned the first word and converted it to numeric. If you want to test first digit only, you must use a numeric function or simply use a character function to extract only first digit (Assuming the number can be more than 1 digit). Mystery 2 solved.

And about the third mystery. You don't give much information. Did you have the 'drop=firstdgc firstdgt' specified too ? ... Mystery 3 solved ????

Corrected code follow: >Data STUF1of2 (drop=firstdgc); >length Var13 $ 13; >set Rawdata1; >Var13=Trim(Var10)||trim(put(indcat,3.));/**to control spaces **/ >firstdgc=scan(Xold,1); >/**** not usefull firstdgt=input(firstdgc,8.);****/ >if substr(firstdgc,1,1) in ('1','2') then Ben='Y'; >else Ben='N'; >run; > >Data STUF2of2 (drop=firstdgc); /* same drop as first ???*/ >[same as far as I can tell except: ] >set Rawdata2

Regards and my deepest sympathies to you and your family,

\\\|/// \\ - - // ( @ @ ) +-----oOOo-(_)-oOOo--+-----------------------------------+ | Bernard Tremblay | | | CSST | Tel: (418) 528-9313 | | | Fax: (418) 528-1493 | | | Int: | +----------------------------+---------------------------+ | Imaginasys enr | Res: (418) 658-1411 | | | Int: | | | Hot: | +--------------Oooo--+-----------------------------------+ oooO ( ) ( ) ) / \ ( (_/ \_) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >From: Mark Moran <Mark.K.Moran@CCMAIL.CENSUS.GOV> >Reply-To: Mark.K.Moran@CCMAIL.CENSUS.GOV >To: SAS-L@LISTSERV.UGA.EDU >Subject: Should be an easy one: Informats etc. >Date: Mon, 7 Aug 2000 16:14:50 -0400 > >Not having a great day today (my Grandmother passed away this morning)... >My >head is swimming but I should be >able to figure this one out. Two, or maybe three, minor mysteries in this >SAS >6.12 datastep: > >I read in Var10 as a $10. variable. I read in Var3 from columns 12-14 as a >numeric. I want Var13 to simply have >13 characters, the first 10 from Var10 and the last 3 from Var3. Whether I >put >trim(Var10) around the variable or >leave it as Var10||indcat, I'm still getting a 10 character variable which >has >the 10 characters from Var10 and >no contribution from indcat. Mystery 1. > >The variable Ben is supposed to check if the first digit of Xold is 1 or 2, >but >it is always coming out N instead of >sometimes Y and sometimes N. Mystery 2. > >I have two identical copies of this datastep, STUF1of2 and STUF2of2. With >Rawdata1, I'm getting the 2 new >variables out of STUF1of2 that I'm expecting (Var13 and Ben), plus for some >reason firstdgc is sticking around! With >the Rawdata2 for some reason I seem to be successfully getting exactly >those >variables I thought I should be getting >out of the datastep, yet I see no difference between the STUF1of2 code and >the >STUF2of2 code. Mystery 3. > >For our own internal policy reasons, I had to change a couple of the >variable >names to ask this question (in case >I've typed something inconsistently and created any fourth or fifth >mysteries!). > > >Data STUF1of2 (drop=firstdgc firstdgt); >length Var13 $ 13; >set Rawdata1; >Var13=Trim(Var10)||indcat; >firstdgc=scan(Xold,1); >firstdgt=input(firstdgc,8.); >if firstdgt in (1,2) then Ben='Y'; >else Ben='N'; >run; > >Data STUF2of2 >[same as far as I can tell except: ] >set Rawdata2 > >- Mark

________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at

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