given a data file with 100 observations of data, you only need to read in the first 70 columns
data have;
do x=1 to 100;
output;
end;
run;
data want;
set have(obs=70);
run;
Ah ok. Do something like this
data have;
array SomeArray{100} x1-x100;
run;
proc sql noprint;
select name into :varnames separated by ' '
from dictionary.columns
where libname="WORK" and memname="HAVE" and varnum<=70
order by varnum;
quit;
%put &varnames.;
data want;
set have;
keep &varnames.;
run;
What kind of data source do you want to read from with this infile statement? a .txt, .xlsx file?
An infile statement is used to read data from an external file.
@thanikondharish wrote:
.xlsx file
Reading a named range is possible if you setup fits - there are some many papers and posts explaining this, i don't like to repeat it. If you don't have a range, you have to import everything and drop the unwanted variables.
You cannot INFILE an XLSX file in DATA step. You need to use an engine that can read the data structure of an Excel spreadsheet.
You can however import a .csv file with the INFILE Statement.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.