Hello,
I want to know how can we sum rowwise data in SAS when the columns are dates. Below is how my Excel file looks like?
Dress_ID | 29/8/2013 | 31/8/2013 | 2/9/2013 | 4/9/2013 | 6/9/2013 | 8/9/2013 |
1006032852 | 2114 | 2274 | 2491 | 2660 | 2727 | 2887 |
1212192089 | 151 | 275 | 570 | 750 | 813 | 1066 |
1190380701 | 6 | 7 | 7 | 7 | 8 | 8 |
966005983 | 1005 | 1128 | 1326 | 1455 | 1507 | 1621 |
876339541 | 996 | 1175 | 1304 | 1396 | 1432 | 1559 |
I want to do sum row wise.
Regards,
Aditya
Use the SUM function.
Sum(var1, var2, ..., varN);
SAS doesn't allow variable names of that type. It will transform them when imported - it would be easier if you modified them manually so you have a system you understand.
If you declare an array you can
array date_vars(12) date1-date12;
total=sum( of date_vars(*));
There are other ways to list the variables based on the convention you choose. Search VARIABLE LIST on here or in SAS documentation.
Use the SUM function.
Sum(var1, var2, ..., varN);
SAS doesn't allow variable names of that type. It will transform them when imported - it would be easier if you modified them manually so you have a system you understand.
If you declare an array you can
array date_vars(12) date1-date12;
total=sum( of date_vars(*));
There are other ways to list the variables based on the convention you choose. Search VARIABLE LIST on here or in SAS documentation.
It is a good idea for you to import that data from Excel and show us what the dataset looks like. That could be a picture for all I know, Excel has no structure or control so it is not possible to work from that point. Once you have a dataset, look at what the variable names are, if they are imported as varX then your problem is a very simple one:
result=sum(of var:);
If they are not, then you may have work in manipulating the data into a useable format.
Thanks for the help.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.