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

I am trying to match two groups. And I have a question about this statement. 

 

what does this code mean? 

 

data matched&n.; set matched&n._1-matched&n._&i.; proc sort data=matched&n.; by aID; run;

 

the bolded part!

 

Thank you so much!

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

Hi @HJ_ and welcome to the SAS Community 🙂

 

I'm guessing that the macro variables &n and &i confuses you. The code in cold simply means that the data step reads all the data sets matched&n._1 to matched&n._i. If &n=1 and &i=3, then that means that three data sets are read. Like below

 

%let n=1;
%let i=3;

data matched1_1;a=1;run;
data matched1_2;a=2;run;
data matched1_3;a=3;run;

data matched&n.;
    set matched&n._1-matched&n._&i.;
run;

Hope this helps. Otherwise, feel free to ask.

View solution in original post

1 REPLY 1
PeterClemmensen
Tourmaline | Level 20

Hi @HJ_ and welcome to the SAS Community 🙂

 

I'm guessing that the macro variables &n and &i confuses you. The code in cold simply means that the data step reads all the data sets matched&n._1 to matched&n._i. If &n=1 and &i=3, then that means that three data sets are read. Like below

 

%let n=1;
%let i=3;

data matched1_1;a=1;run;
data matched1_2;a=2;run;
data matched1_3;a=3;run;

data matched&n.;
    set matched&n._1-matched&n._&i.;
run;

Hope this helps. Otherwise, feel free to ask.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 1 reply
  • 435 views
  • 1 like
  • 2 in conversation