BookmarkSubscribeRSS Feed
jdub
Calcite | Level 5

Hi I have some data that looks like:

order, businessname

1234,Acme

432,Bizarro

55689,Ralph's party town

In the title I mentioned that the variables have different lengths and column starts.  By this I mean that the order numbers have different numbers of characters for each order and that the businessname observations start at different column positions. 

I started my infile with a data step:

data order;

infile 'location.csv' dlm=',' firstobs=2;

input order businessname $;

run;

SAS infiles the first 8 characters of businessname but I am demanding and want the whole enchilada.  If I knew the start column of businessname I would try to grab a field corresponding to businessname, i.e. something like $ 7-26 (Ralph's party town).  The problem is that the Acme observation starts at column 6, Ralph's at column 7 and Bizarro at 5.  How can I code an input statement for the businessname observations to flexibly accomdate this yet also grab all the characters in each observation?

thank you for your help

2 REPLIES 2
art297
Opal | Level 21

You could use:

data order;

  infile 'location.csv' dlm=',' firstobs=2;

  informat businessname $50.;

  input order businessname;

run;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 716 views
  • 3 likes
  • 2 in conversation