BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mj5
Obsidian | Level 7 mj5
Obsidian | Level 7

I have a dataset as below

PT     N

102   25

103   34

Total   .

 

I need to replace the missing with the sum of the 2 counts in N. Can i do that in datastep?

 

1 ACCEPTED SOLUTION
2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Whilst @Kurt_Bremser has given you the answer, I would step back one and ask why you have a dataset which looks like that in the first place.  How have you added "Total" without adding the sum in at the same time, seems like the step before needs changing.  You can add totals on in various ways, my first thought was:

proc sql;
  create table WANT as
  select  *
  from    HAVE
  union all
  select  "Total",
          sum(N) 
  from    HAVE;
quit;

Simply adds a row at the end of the dataset with total.

sas-innovate-2024.png

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.

 

Register now!

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
  • 756 views
  • 1 like
  • 3 in conversation