BookmarkSubscribeRSS Feed
sahoositaram555
Pyrite | Level 9

Hi All,

 

I have a dataset like below 

 

Characteristics

G1

G2

OVERALL

ord

 

 

 

 

2

N

xx.xx(xx.xx%)

xx.xx(xx.xx%)

xx.xx(xx.xx%)

2

Mean(SD)

xx.xx(xx.xx%)

xx.xx(xx.xx%)

xx.xx(xx.xx%)

2

Q2(Q1 Q3)

xx.xx(xx.xx%)

xx.xx(xx.xx%)

xx.xx(xx.xx%)

2

 

 

 

 

5

N

xx.xx(xx.xx%)

xx.xx(xx.xx%)

xx.xx(xx.xx%)

5

Mean(SD)

xx.xx(xx.xx%)

xx.xx(xx.xx%)

xx.xx(xx.xx%)

5

Q2(Q1 Q3)

xx.xx(xx.xx%)

xx.xx(xx.xx%)

xx.xx(xx.xx%)

5

 

 

 

 

1

N

xx.xx(xx.xx%)

xx.xx(xx.xx%)

xx.xx(xx.xx%)

1

Mean(SD)

xx.xx(xx.xx%)

xx.xx(xx.xx%)

xx.xx(xx.xx%)

1

Q2(Q1 Q3)

xx.xx(xx.xx%)

xx.xx(xx.xx%)

xx.xx(xx.xx%)

1

 

 

 

 

3

N

xx.xx(xx.xx%)

xx.xx(xx.xx%)

xx.xx(xx.xx%)

3

Mean(SD)

xx.xx(xx.xx%)

xx.xx(xx.xx%)

xx.xx(xx.xx%)

3

Q2(Q1 Q3)

xx.xx(xx.xx%)

xx.xx(xx.xx%)

xx.xx(xx.xx%)

3

 

 

 

 

 

 

Where characteristics rows are blank i would like to put values like age, weight , height ...etc since the table is very big(80 rows). All the results are coming from inidvidual datasets which i have used a set statement like below

 

Data d;

set OUTPUT_: ;  /*here OUTPUT_: is written to get all the data sets sequentially due to the prefix name "OUTPUT_" is common to all. 

run;

 

Kindly share your ideas how this can be done with macro since i have 22 values to fill in to those blank spaces with age,height,weight ...etc. in a sequential manner.

I'm thinking to assign all the variables in a %let statement and then passing them in to the loop , but don't know how exactly this can be done with the help of a do loop. If any thoughts around this , it will be very helpful.

 

Cheers,

Ram    

 

1 REPLY 1
SwissC
Obsidian | Level 7

Would something like this work?

%LET charnam=Age (years)$Weight (kg)$Height (cm)$BMI (kg/m^2);


DATA want;
  SET have;
  DO i=1 TO 4;
    IF ord=i and characteristics="" THEN characteristics=scan("&charnam", i, "$");
  END;
RUN;

You would of course have to make sure the order in the let statement matches the ord var numbering.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 1 reply
  • 733 views
  • 0 likes
  • 2 in conversation