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

proc transpose gives me a table like in document...

I am trying to write a code so that i can have format like 341/367(93%)--- where 93% is % of row total &

367 is row total so i need:         341/367(93%)        26/367(7%) similar format for rest of table. i am able to do it as

a separate variable in table. but i want to replace value of cutoof60 & 61 in new dataset with new values.

i am making a mistake please help me to rectify the code...

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

PS example data should NEVER be posted in pictures, as that forces everyone else to type data manually off the screen, which means unnecessary work and introduces opportunities for mistakes.

Use data steps with datalines instead:

data tot_trsps;
input trgp_trt cutoff60 cutoff61;
datalines;
1 341 26
2 367 22
;
run;

View solution in original post

3 REPLIES 3
Kurt_Bremser
Super User

Please DO NOT use Office documents for posting such simple things as code, logs or textual data.

Use the "little running man" for code like this:

data tot1;
set tot_trsps;
if trgp_trt=1 then
 cutoff60= put(cutoff60,3.0)||'/'|| put((cutoff60+cutoff61),3.0)||'('||put((cutoff60/(cutoff60+cutoff61))*100,3.1)||'%)';
run;

It is obvious that you try to convert a variable "in place", which is not possible. SAS variables cannot be of type numeric and character within the same step or dataset.

Create a new variable:

cutoff60_char = put(cutoff60,3.0)||'/'|| put((cutoff60+cutoff61),3.0)||'('||put((cutoff60/(cutoff60+cutoff61))*100,3.1)||'%)';
sdeswal
Calcite | Level 5

Thanks a lot for solution and suggestion 

i will keep in mind in next post...

Kurt_Bremser
Super User

PS example data should NEVER be posted in pictures, as that forces everyone else to type data manually off the screen, which means unnecessary work and introduces opportunities for mistakes.

Use data steps with datalines instead:

data tot_trsps;
input trgp_trt cutoff60 cutoff61;
datalines;
1 341 26
2 367 22
;
run;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 936 views
  • 0 likes
  • 2 in conversation