i can do this using proc sql but my variables are 100 so it will take lot of time .Is their any other way so that i haven't to wright 100 variable in select statement
data a;
input s1 s2 s3 s4;
datalines;
1 2 3 4
2 2 4 5
9 9 9 9
;
run;
output
s1 s2 s3 s4
12 13 16 18
This is where the various analysis and reporting PROCs in SAS excel. In your case, it would be PROC SUMMARY:
data a;
input s1 s2 s3 s4;
datalines;
1 2 3 4
2 2 4 5
9 9 9 9
run;
proc summary data=a ;
var s1-s4;
output out=want (drop=_type_ _freq_) sum=;
run;
Assuming your variables are named s1 to s100 something like this should work:
proc summary data = a sum;
var s1 - s100;
output out = a_sum
sum = ;
run;
What do you need exactly as result? A dataset with the sums? Html-Output? The sums appended to the dataset you have?
Using proc summary is highly recommended, but if you can use IML, this maybe a good point to start, because it is designed to work with matrices.
proc iml;
use work.a;
read all var _num_ into have;
close work.a;
want = have[+,];
print want;
quit;
Transpose!
There are just a few scnarios when a wide table make s sense.
A long table structure is easier to query, optimizes storage etc.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.