BookmarkSubscribeRSS Feed
rajeshalwayswel
Pyrite | Level 9
data have;
input xyz a b c total;
cards
a       1     2         3         6
b       4     5         6        15
c       2     3         4          9
total   7    10       13       30
run;

required:

vertical a column total 7 need to divide with all a veriable vertical rows only similarly vertical b,c,total

4 REPLIES 4
Kurt_Bremser
Super User

Start by posting working code:

24         data have;
25         input xyz a b c total;
26         cards
27         a       1     2         3         6
           _
           22
           76
ERROR 22-322: Syntax error, expecting one of the following: ;, CANCEL, PGM.  

ERROR 76-322: Syntax error, statement will be ignored.

28         b       4     5         6        15
29         c       2     3         4          9
30         total   7    10       13       30
31         run;
32         
33         
34         GOPTIONS NOACCESSIBLE;
35         %LET _CLIENTTASKLABEL=;
36         %LET _CLIENTPROJECTPATH=;
37         %LET _CLIENTPROJECTNAME=;
38         %LET _SASPROGRAMFILE=;
NOTE: DATA statement used (Total process time):
      real time           0.05 seconds
      cpu time            0.00 seconds
      
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.HAVE may be incomplete.  When this step was stopped there were 0 observations and 5 variables.

rajeshalwayswel
Pyrite | Level 9

Thanks for the inputs. I'll put my efforts.

Tom
Super User Tom
Super User

That looks like a cross tab.  Why not start with the raw data and let SAS generate the report you need?

data have;
  length var1 var2 $8 amount 8;
  input var1 $ @ ;
  do var2='a','b','c';
    input amount @ ;
    output;
  end;
cards;
a   1 2 3
b   4 5 6
c   2 3 4
;

proc freq data=have ;
  tables var1*var2 ;
  weight amount ;
run;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2506 views
  • 3 likes
  • 3 in conversation