BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
109393
Calcite | Level 5

 

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;
  

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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;

View solution in original post

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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;

Kurt_Bremser
Super User

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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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