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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.