please can someone please explain to me what the following codes do
rc=filename ("fdir","&path");
macro readf(p);
data _null_;
set dirlist nobs=n;
call symput ('f'||compress(_n_),trim(left(fname)));
call symput ('nf', compress(n));
run;
%do i = 1 %to &nf;
%put &p.\&&f&i;
What part of that code do you need expaining, i.e. what is the question? Judging by this and your other question, you would be best off starting by learning SAS, Base SAS and Macro SAS. You can learn this by using the help videos given by SAS, doing a course, reading the manual etc.
At a brief glimpse:
rc=filename ("fdir","&path");
rc is a variable which holds the result of calling the function filname. I.e. rc stands for Return Code.
The below is a macro - a text generation tool - it creates some macro varibales and then start to DO a loop. You are missing a % before macro, and my first question would be why are you doing it this way in the first place?
macro readf(p);
data _null_;
set dirlist nobs=n;
call symput ('f'||compress(_n_),trim(left(fname)));
call symput ('nf', compress(n));
run;
%do i = 1 %to &nf;
%put &p.\&&f&i;
What part of that code do you need expaining, i.e. what is the question? Judging by this and your other question, you would be best off starting by learning SAS, Base SAS and Macro SAS. You can learn this by using the help videos given by SAS, doing a course, reading the manual etc.
At a brief glimpse:
rc=filename ("fdir","&path");
rc is a variable which holds the result of calling the function filname. I.e. rc stands for Return Code.
The below is a macro - a text generation tool - it creates some macro varibales and then start to DO a loop. You are missing a % before macro, and my first question would be why are you doing it this way in the first place?
macro readf(p);
data _null_;
set dirlist nobs=n;
call symput ('f'||compress(_n_),trim(left(fname)));
call symput ('nf', compress(n));
run;
%do i = 1 %to &nf;
%put &p.\&&f&i;
Google is your friend. Really. I mean it.
Everytime you see a statement/function/format/whatever you're not familiar with, enter "SAS whatever_you_want_to_know_about" into big G, and you'll get the respective documentation, most often as the first hit.
It's what I do when I stumble across something I haven't seen yet, or haven't used for a long time, or am not very familiar yet.
All the "old hands" around here do it.
If you then have a more specific question, come here. But this community is intended as a help for advanced problems, not as the place for initial learning. This is done in the courses you have already been pointed to.
We're the track&field coaches and dance instructors, but we expect you already have learned how to walk.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.