BookmarkSubscribeRSS Feed
Tiny_Kane
Obsidian | Level 7

Hello~

I have made a table as below. But my target two tables are a little different. Does any one know how to modify the code to edit the table to be the target two tables?

age

  1. 61.82 (11.02)
  2. 61.73 (11.28)

sex

437 (33.16)

73 (35.44)

Education, %

1=HighSchoolorLess

567 (43.05)

81 (39.32)

2=SomeCollege

403 (30.60)

61 (29.61)

3=CollegeGraduate

347 (26.35)

64 (31.07)

Race/Ethnicity

1=Non-HispanicWhite

1096 (83.60)

175 (85.37)

2=Non-HispanicBlack

179 (13.65)

21 (10.24)

3=Hispanic

36 (2.75)

9 (4.39)

Medical History

mh_chd

500 (39.87)

80 (41.03)

mh_mi

339 (27.03)

53 (27.18)

mh_chf

152 (12.12)

25 (12.82)

mh_stroke

55 (4.39)

8 (4.10)

mh_diabetes_2

375 (29.90)

62 (31.79)

mh_hyperl

885 (70.57)

127 (65.13)

mh_af

98 (7.81)

24 (12.31)

mh_alz

1 (0.08)

0 (0.00)

mh_cld

233 (18.58)

43 (22.05)

mh_ckd

121 (9.65)

22 (11.28)

alcohol_base

122 (9.28)

11 (5.34)

smoke_base

281 (21.32)

39 (18.93)

The above table is what I get now…. The code I used is

proc format;

value rowheadr 0=" "

               1=" "

                     2="Education, %"

                     3="Race/Ethnicity"

                     4="Medical History";

run;

proc report data=test nowd style(lines)=[just=l];

column position subposition char nore eare;

define position / group order=internal noprint;

define subposition/group order=internal noprint;

define char / order = data style(column) = [font_size=3 just=left] width=70;

define nore / order = data style(column) = [font_size=3 just=center] width=70;

define eare    / order = data style(column) = [font_size=3 just=center];

compute char;

if position^=0 and position^=1 then

call define("char","style", "style={indent=0.25 in}");

endcomp;

compute before position;

line position rowheadr.;

endcomp;

run;

The first target table is below: how to delete the first and third blank rows? How to make the row header lines the same as other lines, I mean adding the column lines?

age

  1. 61.82 (11.02)
  2. 61.73 (11.28)
sex437 (33.16)73 (35.44)
Education, %
1=HighSchoolorLess567 (43.05)81 (39.32)
2=SomeCollege403 (30.60)61 (29.61)
3=CollegeGraduate347 (26.35)64 (31.07)
Race/Ethnicity
1=Non-HispanicWhite1096 (83.60)175 (85.37)
2=Non-HispanicBlack179 (13.65)21 (10.24)
3=Hispanic36 (2.75)9 (4.39)
Medical History
mh_chd500 (39.87)80 (41.03)
mh_mi339 (27.03)53 (27.18)
mh_chf152 (12.12)25 (12.82)
mh_stroke55 (4.39)8 (4.10)
mh_diabetes_2375 (29.90)62 (31.79)
mh_hyperl885 (70.57)127 (65.13)
mh_af98 (7.81)24 (12.31)
mh_alz1 (0.08)0 (0.00)
mh_cld233 (18.58)43 (22.05)
mh_ckd121 (9.65)22 (11.28)
alcohol_base122 (9.28)11 (5.34)
smoke_base281 (21.32)39 (18.93)

  The second target table is below, how to make the box for each variable?     

age
  1. 61.82 (11.02)
  2. 61.73 (11.28)

sex

437 (33.16)

73 (35.44)

Education, %

1=HighSchoolorLess

567 (43.05)

81 (39.32)

2=SomeCollege

403 (30.60)

61 (29.61)

3=CollegeGraduate

347 (26.35)

64 (31.07)

Race/Ethnicity

1=Non-HispanicWhite

1096 (83.60)

175 (85.37)

2=Non-HispanicBlack

179 (13.65)

21 (10.24)

3=Hispanic

36 (2.75)

9 (4.39)

Medical History

mh_chd

500 (39.87)

80 (41.03)

mh_mi

339 (27.03)

53 (27.18)

mh_chf

152 (12.12)

25 (12.82)

mh_stroke

55 (4.39)

8 (4.10)

mh_diabetes_2

375 (29.90)

62 (31.79)

mh_hyperl

885 (70.57)

127 (65.13)

mh_af

98 (7.81)

24 (12.31)

mh_alz

1 (0.08)

0 (0.00)

mh_cld

233 (18.58)

43 (22.05)

mh_ckd

121 (9.65)

22 (11.28)

alcohol_base

122 (9.28)

11 (5.34)

smoke_base

281 (21.32)

39 (18.93)

Thanks in advance~

7 REPLIES 7
Tiny_Kane
Obsidian | Level 7

Sorry, tables lost some parts whiling copying from world.....

Cynthia_sas
SAS Super FREQ

Hi: Urgent requests for help should go to Tech Support. They can look at all your code, including your ODS statements, which you do not show here. The destination that you use will be important. I do not understand what destination you are using that would create this output from the code you show. You do not show any ODS statements, you do not show the style template that you used with ODS.


You are asking these questions and I do not understand what you mean:

-- code to edit the table to be the target two tables

-- how to delete the first and third blank rows? (I don't see "blank" rows in the first table. I see rows with Education and Medical History, etc...are those what you mean)

--  How to make the row header lines the same as other lines, I mean adding the column lines? By row header lines, do you mean things like Education and Medical History? Those seem to be set with a user-defined format.

-- how to make the box for each variable (do you mean issues with interior table lines? Again, this depends on the style you're using and your ODS destination and you have not shown those with your code)


  No one will really be able to help you unless you share ALL your code and your data so they can run the program. Also, they need to know your destination of choice, otherwise, people will try the code in the default HTML destination -- if they even try the code at all, because to try your code, they need to guess at what your data looks like.


  I do have some comments -- the simple WIDTH=70 will be ignored by ODS destinations -- that is a LISTING only option. if you want to impact the width of the cell in the ODS output, you need to use a STYLE= override.


  Overall, I think your best resource for help with this output is to work with Tech Support.


cynthia

Tiny_Kane
Obsidian | Level 7

Hi~

When I copied the tables from word document, some parts were losing, and I could not upload the document because this forum restrict it. Do you have other way that I can send you the whole tables? I have contacted with SAS tech support, but they said I have to contact with SAS consulting regarding to my question. But SAS consulting cannot help me at this stage...I am totally hopeless, that's why I sent those stuffs here....This is very urgent...Can you help me?

Reeza
Super User

Save your word document to a PDF file and upload that instead.

Tiny_Kane
Obsidian | Level 7

This is the data set I made for the proc report.

Reeza
Super User

Well you can manually delete the rows you don't need from the table above as a starter Smiley Happy

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 7 replies
  • 755 views
  • 0 likes
  • 3 in conversation