BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
elopomorph
Calcite | Level 5

I want to tell SAS to read columns 1 to 500.  I could tell it to read COL1 COL2 COL3 ... COL500 but that would take forever.  

 

Here is a more detailed example

VAR  COL1 COL2 COL3 COL4 COL5 COL6 COL7 ............................................  COL500

 

Is there a shorter way to tell SAS to read the columns?

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

And if you are reading an external file you can use a range list on the input statement:

 

input var1 col1-col500;

Or

input var1 col001 - col500;

 

View solution in original post

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Yes several:

data want;

  set have;

  keep=col1-col500;

  /* Or */

  keep=col:;

  /* Or */

  array col{500};

  do i=1 to 500;

    ...;

  end;

run;

ballardw
Super User

And if you are reading an external file you can use a range list on the input statement:

 

input var1 col1-col500;

Or

input var1 col001 - col500;

 

elopomorph
Calcite | Level 5

very helpful. Thanks!  

AnnaBrown
Community Manager

Hi elopomorph,

 

I'm glad you found some useful info! If one of the replies was the exact solution to your problem, can you "Accept it as a solution"? Or if one was particularly helpful, feel free to "Like" it. This will help other community members who may run into the same issue know what worked.

 

Thanks!

Anna


Join us for SAS Community Trivia
SAS Bowl XXIX, The SAS Hackathon
Wednesday, March 8, 2023, at 10 AM ET | #SASBowl

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1004 views
  • 1 like
  • 4 in conversation