BookmarkSubscribeRSS Feed
sasuser123123
Quartz | Level 8

Hi Everyone.

I have a data like..

Data new;
Input visit $ stats$ ;
cards;
baseline n
baseline mean
baseline sd
baseline min
visit1 n
visit1 mean
visit1 sd
visit1 min
visit2 n
visit2 mean
visit2 sd
visit2 min
;
run;
I want to add one extra row and want some changes like visit and stats should comes under a single variable as shown in below .
My output should like..
  new                          visit        stats
Baseline analysis
n                                baseline   n
mean                         baseline   mean

sd                              baseline   sd
min                            baseline   min
Analysis at visit1
n                                visit1        n
mean                         visit1        mean
sd                              visit1        sd
min                            visit1        min
Analysis at visit2
n                               visit2         n
mean                        visit2         mean
sd                              visit2        sd
min                            visit2        min

Could anyone help me out how to get it.. Please ignore any spelling mistakes and alignment. I typed in mobile
Thank you

7 REPLIES 7
ballardw
Super User

What content in the data set tells us where to insert rows? Rules for the content of the "row".

What specific variable is to contain that text? How long is that variable defined to be? If you try to stick more than 8 letters into a variable defined as length 8 it just won't fit.

 

And lastly, how do you expect to use this data set? Inserting random text often is not the way to work in SAS and combining multiple values into a single variable is quite often very much harder to do anything with.

sasuser123123
Quartz | Level 8
I just updated my query please recheck once.
Reeza
Super User
Do you actually need this as a data set or as an output for a report? ie would the output in Word/Excel/PDF be fine?

If so, you need PROC REPORT.
sasuser123123
Quartz | Level 8
We need a final dataset looks my output for proc report right?
Reeza
Super User

No, your input data set is set up fine for PROC REPORT, however if you want more help beyond just use PROC REPORT I would suggest posting actual data. 

 

 

sasuser123123
Quartz | Level 8
Usually I used that scenario..I didn't try in proc report...any inputs
Reeza
Super User
COMPUTE BEFORE most likely.

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