BookmarkSubscribeRSS Feed
dali74
Fluorite | Level 6

 i have a dataset like this:

 

 

 

 

var1     var2    var3........varn
10      4         5           8

 

 

 

and other data with

 

 

var
1
2
2 .... 1

 

 

I would like to create a dataset with rest of var1 and obs(1,var)

 

 

 

rest
10-1=9
2
3
..
7

is it possible?

 

 

 

1 REPLY 1
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Have a look at the guidance when posting questions, its next to the Post button.  Provide test data in the form of a datastep in a code window, and show required output.  As I am not typing that out, here is a best guess:

proc transpose data=other_data out=t_other prefix=rest;
  var var;
run;

data want;
  merge have t_other;
  array var{10};
  array rest{10};
  array res{10};
  do i=1 to 10;
    res{i}=var{i}-rest{i};
  end;
run;

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
  • 1 reply
  • 534 views
  • 0 likes
  • 2 in conversation