BookmarkSubscribeRSS Feed
laxmanpai
Calcite | Level 5

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

 

2 REPLIES 2
Tom
Super User Tom
Super User

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.

PaigeMiller
Diamond | Level 26

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.

--
Paige Miller

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 271 views
  • 0 likes
  • 3 in conversation