SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

write shorthand code in sas

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 8
Accepted Solution

write shorthand code in sas

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?

 

 

 

 

 


Accepted Solutions
Solution
‎11-19-2015 09:25 AM
Super User
Posts: 11,343

Re: write shorthand code in sas

Posted in reply to elopomorph

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


All Replies
Super User
Super User
Posts: 7,965

Re: write shorthand code in sas

Posted in reply to elopomorph

Yes several:

data want;

  set have;

  keep=col1-col500;

  /* Or */

  keep=col:;

  /* Or */

  array col{500};

  do i=1 to 500;

    ...;

  end;

run;

Solution
‎11-19-2015 09:25 AM
Super User
Posts: 11,343

Re: write shorthand code in sas

Posted in reply to elopomorph

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;

 

Occasional Contributor
Posts: 8

Re: write shorthand code in sas

very helpful. Thanks!  

Community Manager
Posts: 564

Re: write shorthand code in sas

Posted in reply to elopomorph

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

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

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