Hello guys,
I have a table like the below,
var1 var2 var3 var4 var5
npass 23 34 27 43
nfail 20 18 37 16
npper 23/43 34/52 27/64 43/59
nfper 20/43 18/52 37/64 16/59
what I want is :
var1 var2 var3 var4 var5
npass 23 (53.4%) 34 (65.4%) 27 (42.2%) 43 (72.9%)
nfail 20(46.6%) 18 (34.6%) 37 (57.8%) 16 (27.1%)
npper is passing percent , nfper is failing percent. the Var2 var3 var4 var5' s names are macro values. those macro values changes month by month.
Thanks a lot!
@daisy6 wrote:
I want a table as data set. The percents and pass number in the exact same cell of the dataset.
The idea of having a cell in a SAS data set that contains the text "23 (53.4%)" seems utterly useless to me. What possible use of such a data set could there be?
However, if you really want to do this, you create a data set where the calculations are done and there are numbers in each cell, 23 in one cell, 53.4 in another cell (PROC SUMMARY could do this easily), and then using a data step, convert these values to characters and concatenate them. I do not have the time today to advise further on the exact code. Please see if you can make this work based upon the description I have given.
Do you want a table (for example from PROC REPORT) as output, or data set as output?
In either case, do you want the percents in the exact same cell of the table/data set, or are the percents in a different column?
I want a table as data set. The percents and pass number in the exact same cell of the dataset.
Thank you
@daisy6 wrote:
I want a table as data set. The percents and pass number in the exact same cell of the dataset.
The idea of having a cell in a SAS data set that contains the text "23 (53.4%)" seems utterly useless to me. What possible use of such a data set could there be?
However, if you really want to do this, you create a data set where the calculations are done and there are numbers in each cell, 23 in one cell, 53.4 in another cell (PROC SUMMARY could do this easily), and then using a data step, convert these values to characters and concatenate them. I do not have the time today to advise further on the exact code. Please see if you can make this work based upon the description I have given.
PaigeMiller, thank you for your suggestions. I used your method to solve that problem.
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!
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.