BookmarkSubscribeRSS Feed
subhasr
Calcite | Level 5

Hi, 

I am new to SAS community. I have a small problem with do loops while using macro. I want to get Bill_1, bill_2 , bill_3 which is assigned as i (bill_&i). I also want stat_1, stat_2 and stat_3 which is assigned as j (stat_&j).

Now I write a do loop for %do i= 1 %to 3;
                                       %do j= 1 %to 3;

So definitely its getting looped 9 times. But I want it to produce just 3 combinatuions like this.  Bill_1,Stat_1

                                                                                                                                                    Bill_2,Stat_2

                                                                                                                                                    Bill_3,Stat_3.

If I could get some help please.

3 REPLIES 3
Haikuo
Onyx | Level 15

Can you assign them using the same macro variable, say i and do one loop?

 

bill_&i, stat_&i

 

 %do i= 1 %to 3

subhasr
Calcite | Level 5

 

Yipeeeeeee it worked. Thanks a lot Haikuo. Man Very Happy

kannand
Lapis Lazuli | Level 10

Please accept @Haikuo's solution so you give "he or she" the credit and remove this problem from the pending queue. Of course when time permits. 

 

By the way, welcome to the forum...!!!

Kannan Deivasigamani

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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