DATA Step, Macro, Functions and more

determining corrent column

Reply
Super Contributor
Posts: 326

determining corrent column

hi

is there a way to determine the current column being read by sas and the stop reading the current record and go to the next one?

let's say main table contains 10 columns. i want to read only columns 1-5.

and what if i want to read columns 1-5,then 6-10?

data x;
set main;
.
.
run;

thanks a bunch!
Valued Guide
Posts: 2,177

Re: determining corrent column

yes.
but with so many possibilities and so little information about your data I thìnk the best advice for you would be to read up on infile options COLUMN, LRECL and a lot of examples of the INPUT statement.
It is one of the richest parts of the SAS language functionality. imho

PeterC
PROC Star
Posts: 1,760

Re: determining corrent column

You have a set statement there, not an infile statement.

If this is what you mean, sas reads all columns at once. Read the about the program data vector in the online doc.
N/A
Posts: 0

Re: determining corrent column

Hi,

To control observations we can use _N_ which stores the observation number which sas is processing. you can subset your dataset by writing conditions on _N_.

and there are two direct options FIRSTOBS,OBS

if you set FIRSTOBS option to 6 and OBS to 10
sas starts reading from 6th observation to 10 th observation

Hope this will help you,

Regards,
skm
Ask a Question
Discussion stats
  • 3 replies
  • 115 views
  • 0 likes
  • 4 in conversation