BookmarkSubscribeRSS Feed
thanikondharish
Fluorite | Level 6

Name

Age

Sex

Height

Weight

Alfred

14

M

69

112.5

Alice

13

F

56.5

84

Barbara

13

F

65.3

98

Carol

14

F

62.8

102.5

Henry

14

M

63.5

102.5

James

12

M

57.3

83

Jane

12

F

59.8

84.5

Janet

15

F

62.5

112.5

Jeffrey

13

M

62.5

84

John

12

M

59

99.5

Joyce

11

F

51.3

50.5

Judy

14

F

64.3

90

Louise

12

F

56.3

77

Mary

15

F

66.5

112

Philip

16

M

72

150

Robert

12

M

64.8

128

Ronald

15

M

67

133

Thomas

11

M

57.5

85

William

15

M

66.5

112

 

i have sashelp.class data

how to create a new variable like sequence variable within proc report see below

 

Name

Age

Sex

Height

Weight

sequence

Alfred

14

M

69

112.5

1

Alice

13

F

56.5

84

2

Barbara

13

F

65.3

98

3

Carol

14

F

62.8

102.5

4

Henry

14

M

63.5

102.5

5

James

12

M

57.3

83

6

Jane

12

F

59.8

84.5

7

Janet

15

F

62.5

112.5

8

Jeffrey

13

M

62.5

84

9

John

12

M

59

99.5

10

Joyce

11

F

51.3

50.5

11

Judy

14

F

64.3

90

12

Louise

12

F

56.3

77

13

Mary

15

F

66.5

112

14

Philip

16

M

72

150

15

Robert

12

M

64.8

128

16

Ronald

15

M

67

133

17

Thomas

11

M

57.5

85

18

William

15

M

66.5

112

19

 

4 REPLIES 4
Jagadishkatam
Amethyst | Level 16

Will it work, 

 



data class; set sashelp.class; sequence=_n_; run; PROC REPORT DATA=WORK.CLASS LS=102 PS=56 SPLIT="/" CENTER ; COLUMN Name Sex Age Height Weight sequence; DEFINE Name / DISPLAY FORMAT= $8. WIDTH=8 SPACING=2 LEFT "Name" ; DEFINE Sex / DISPLAY FORMAT= $1. WIDTH=1 SPACING=2 LEFT "Sex" ; DEFINE Age / SUM FORMAT= BEST9. WIDTH=9 SPACING=2 RIGHT "Age" ; DEFINE Height / SUM FORMAT= BEST9. WIDTH=9 SPACING=2 RIGHT "Height" ; DEFINE Weight / SUM FORMAT= BEST9. WIDTH=9 SPACING=2 RIGHT "Weight" ; DEFINE sequence / SUM FORMAT= BEST9. WIDTH=9 SPACING=2 RIGHT "sequence" ; RUN;
Thanks,
Jag
thanikondharish
Fluorite | Level 6
you created variable in data step block.
but i want to create variable in proc block(proc report)
Ksharp
Super User
proc report data=sashelp.class nowd;
columns  name age weight n;
define name/display;
define n/computed 'Sequence';
compute n;
 _n+1;
 n=_n;
endcomp;
run;
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1818 views
  • 5 likes
  • 4 in conversation