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

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 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

It really helps to provide an example of what the expected output should be.

You say "Where characteristics rows are blank i would like to put values like age, weight , height ".

 

So, where are we supposed to get the values from? How do we know which row is supposed to have what? Exactly what appears where?

You can get the name of a contributing data set using the INDSNAME option so you can parse that if needed to set the value of one or more variables in your data. A brief example:

data example;
   set 
       sashelp.class (obs=1 keep=height weight)
       sashelp.heart (obs=1  keep=height weight)
       indsname= ds
  ;
  length set $ 32;
  set = scan(ds,2,'.');
run;

which gets the name of the data set without the library.

You can also use the CUROBS option on the Set statement to get the number of the observation from the contributing data set. So you can do an action with your data that only needs to be done with the first observation.

data example;
   set 
       sashelp.class (obs=2 keep=height weight)
       sashelp.heart (obs=2  keep=height weight)
       indsname= ds    curobs=c
  ;
  length set $ 32;
  set = scan(ds,2,'.');
  orobs=c;
run;

 

Which brings up actually having data to manipulate, i.e. a data step that will create an example of one or more of your data sets.

 

Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

 

View solution in original post

2 REPLIES 2
pau13rown
Lapis Lazuli | Level 10

you already have the 'ord' variable in the dataset. Thus, just put a format on it and then in proc report have eg:

 

compute before ord;
line @1 ord $ord_f.;
endcomp;

it won't fill in the rows in the dataset but i assume ultimately you want to display the output using eg proc report. Otherwise use a put statement with the format in the datastep

ballardw
Super User

It really helps to provide an example of what the expected output should be.

You say "Where characteristics rows are blank i would like to put values like age, weight , height ".

 

So, where are we supposed to get the values from? How do we know which row is supposed to have what? Exactly what appears where?

You can get the name of a contributing data set using the INDSNAME option so you can parse that if needed to set the value of one or more variables in your data. A brief example:

data example;
   set 
       sashelp.class (obs=1 keep=height weight)
       sashelp.heart (obs=1  keep=height weight)
       indsname= ds
  ;
  length set $ 32;
  set = scan(ds,2,'.');
run;

which gets the name of the data set without the library.

You can also use the CUROBS option on the Set statement to get the number of the observation from the contributing data set. So you can do an action with your data that only needs to be done with the first observation.

data example;
   set 
       sashelp.class (obs=2 keep=height weight)
       sashelp.heart (obs=2  keep=height weight)
       indsname= ds    curobs=c
  ;
  length set $ 32;
  set = scan(ds,2,'.');
  orobs=c;
run;

 

Which brings up actually having data to manipulate, i.e. a data step that will create an example of one or more of your data sets.

 

Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1609 views
  • 1 like
  • 3 in conversation