Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading Data with Varying Length

Status
Not open for further replies.

proximo20

Technical User
Sep 29, 2009
22
0
0
US

When the length of strings are different we use $varyingw. What do we use when numeric values have varying length.

Ex.

code price size

aaa 3000 400
bbb 200 5000
ddd 50000 60

Thanks
 
Actually the data does not have titles I assign them with the input command.

aaa 3000 400
bbb 200 5000
ddd 50000 60
 
Thanks again Mdieckman! My problem is this

I got this data

XYZAA 20080721 2 1420 10022 A N N
XYZAA 20080721 2 1421 11001 A N N
XYZAA 20080721 2 1421 9877 A N N

I need to give them titles so I use this:

INPUT code $ 1-5 date 7-14 session 16 hour 18-21 price 6. type $ 29 market $ 31 correction $ 33;

My problem is that the input statement reads the price values 10022 and 11001 but it does not read 9877 and gives error for that line. When I use 5. then it reads the values as 1002, 1100(instead of 10022 and 11001) and 9877.

I tried to use : & and +1 but they don't work either.

I don't use export because the extension of files are .ts and I don't know what I should use for dbms=?



 
Ok I got it. I am using two input statements, if price is bigger than 10000 and if it is less than.
 
Alternatively this might work. Treat it as a space delimited file.
Code:
data test;
  infile blah recfm=v lrecl=2056 dlm=' ' missover;

  length code $5 
         date 8
         session 4
         hour 4
         price 6.
         type $1
         market $1
         correction $1;

  informat date yymmdd8.;

  input code
        date
        session
        hour
        price
        type
        market
        correction;
run;

Chris
Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top