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

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!

  

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

@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.

 

 

--
Paige Miller

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

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?

 

 

 

--
Paige Miller
daisy6
Quartz | Level 8

I want a table as data set. The percents and pass number in the exact same cell  of the dataset. 

 

Thank you

PaigeMiller
Diamond | Level 26

@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.

 

 

--
Paige Miller
daisy6
Quartz | Level 8

PaigeMiller, thank you for your suggestions.  I used your method to solve that problem.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 4 replies
  • 777 views
  • 0 likes
  • 2 in conversation