BookmarkSubscribeRSS Feed
milts
Pyrite | Level 9
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!
3 REPLIES 3
Peter_C
Rhodochrosite | Level 12
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
ChrisNZ
Tourmaline | Level 20
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.
deleted_user
Not applicable
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

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 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
  • 3 replies
  • 649 views
  • 0 likes
  • 4 in conversation