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 2008, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 10 Jun 2008 16:25:12 -0400
Reply-To:   msz03@albany.edu
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Mike Zdeb <msz03@ALBANY.EDU>
Subject:   Re: reading variables enclosed in quotes
Content-Type:   text/plain;charset=iso-8859-1

hi ... I thought this looked neat so I tried it with the data provided and giot an unexpected result ...

data y; infile datalines dsd dlm= ' ' firstobs= 2 ; length name $20 age 8 state $2 ; input name age state ; datalines; "Name" "Age" "State" "Smith" "22" "NJ" "Tom" "44" "CT" "Shake" "34" "CA" ; run;

proc print data=y; run;

produces ...

Obs name age state 1 Smith . 22 2 Tom . 44 3 Shake . 34

I used the $QUOTE informat and that seemed to work OK ...

data x; infile datalines firstobs=2; input (name temp state) (: $quote.); age = input(temp,best.); drop temp; datalines; "Name" "Age" "State" "Smith" "22" "NJ" "Tom" "44" "CT" "Shake" "34" "CA" ; run;

-- Mike Zdeb U@Albany School of Public Health One University Place Rensselaer, New York 12144-3456 P/518-402-6479 F/630-604-1475

> On Jun 10, 8:56 pm, rmat <reg...@gmail.com> wrote: >> Hi >> >> I am trying to read a text file containing variables enclosed in >> quotes like given below. There are space between variables. Can you >> please help me to read this data into SAS? >> >> "Name" "Age" "State" >> "Smith" "22" "NJ" >> "Tom" "44" "CT" >> "Shake" "34" "CA" >> --- >> --- >> --- >> --- >> --- >> Thanks very much, Regi > > data ; > infile yourdata DSD dlm= ' ' firstobs= 2 ; > length name $20 age 8 state $2 ; > input name age state ; > run; > >


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