BookmarkSubscribeRSS Feed
mrajendranvasanthi
Fluorite | Level 6

I am trying to read large number of files. Here i am using this variable topfile to add values everytime a file is read and add it as a column in my final dataset.

%if %sysfunc(exist(mv.movers_signals_all))= 0 %then %do;

/*%local topfile; */

%let %topfile=1;

%end;

%else %do;

%let topfile=%eval(&topfile+1)

proc sql;

select max(topfile)  into :topfile

from mv.movers_signals_all;

quit;

%end;

%put &topfile;

proc sql;

create table mv.moversdata2_&filen. as

select "&filen" as filedate, "%topfile" as topfile,*

from mv.moversdata_&filen.;

quit;

I am trying to read large number of files. Each file has about 50k observations. I want to differentiate between files and Here i am using this variable "topfile" to add values everytime a file is read and add it as a column in my final dataset. But while trying to add values in that macro variable, i am getting this error.

ERROR: Expression using addition (+ ) requires numeric types.

2 REPLIES 2
PGStats
Opal | Level 21

Make sure you know when to use & and % in macro expressions. I see two syntax errors. They should be:

%let topfile=1;

and

select "&filen" as filedate, "&topfile" as topfile,*


PG

PG
Reeza
Super User

%let topfile=%eval(&topfile. +1)


If your files all have the same structure and are in the same folder you can use something like the following instead:

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 3278 views
  • 0 likes
  • 3 in conversation