Hi Team,
I have the data as below
A | Jan-23 | 52,332 |
A | Feb-23 | 51,800 |
A | Mar-23 | 53,765 |
A | May-23 | 50,879 |
A | Jun-23 | 52,543 |
A | Jul-23 | 82,640 |
A | Oct-23 | 57,243 |
A | Dec-23 | 60,763 |
B | Feb-23 | 1,12,332 |
B | Mar-23 | 82,843 |
B | Jun-23 | 85,851 |
B | Aug-23 | 84,008 |
B | Sep-23 | 86,715 |
B | Oct-23 | 1,17,855 |
B | Nov-23 | 93,501 |
B | Dec-23 | 98,064 |
I want to insert a row which should read as below
A Apr-23 53765
B Jan-23 20
I also want to get the totals based on the Employee Id. Could you help me here
What is the name of the dataset? What are the names of the variables? What is the type of the variables? If the variable is character what is its defined maximum storage length? Do the variables have any formats attached them? If so what format?
Looks like you want to add two observations.
You could make a new dataset and append it. Do you know how to make a dataset? Do you know how to use the SET statement? Or the MERGE statement? or PROC APPEND?
You could also use the SQL INSERT statement.
Please go back to your ORIGINAL subject line and change "columns" to "rows"
data extra;
employee_id='A'; date='01APR2023'd; amount=53765; output;
employee_id='B'; date='01JAN2023'd; amount=20; output;
run;
data want;
set have extra;
run;
/* Get sums by employee_id */
proc summary data=want nway;
class employee_id;
var amount;
output out=sums sum=;
run;
Please, in the future, provide data not as a screen capture from Excel, and not via file attachments, but by creating working SAS data step code (examples and instructions) and including this code in your question. Screen captures are not acceptable, for reasons pointed out by @Tom, and so we consider it mandatory that you provide data in working SAS data step code.
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.