BookmarkSubscribeRSS Feed
achufa
Calcite | Level 5

Hi

I would like to get the list of columns from a group named "GROUP" (Column 1, Column 2, etc); then create another list on columns, dynamically as a loop, in which I would take each column from list "GROUP", assign a new name such as "Column 1 Duplicated", "Column 2 Duplicated", etc.  and assign a formula for each new column, like  = "Column 1" / 10

thanks

Alex

5 REPLIES 5
Haikuo
Onyx | Level 15

The answers would have been much prompt if you can provide a dummy sample input data, and expected outcome. Description alone is too vague.

achufa
Calcite | Level 5

Hi  Hai.kuo

ok, here is what I would like to do

I have an original table, containing the following columns:

Population, Test1, Test2, Test3,  etc.

Columns 2, 3 and 4 are conbined in a group called "TARGETS".

All Test... columns are numeric, continuous values.

I would like to make a script which would do the following

1. Get a list of columns from a group "TARGETS" (will contain columns Test1, Test2, Test3)

2. Will create 3 new columns, calling each column New_Test1, New_Test2, New_Test3

3. Will assign a formula for each of the new columns, such as New_Test1 = Test1/10.

hope this explains my case

thanks

ballardw
Super User

Example data should be in a tabular form indicating the variable names. Input data is best provided as a data step code so that we can manipulate the examples.

Output should look show what the final result would look like and the rules provided.

Your example looks like an array process. Arrays are the basic method for handling groups of related variables especially for identical or very similar processes.

data want;

     set have;

     array test test1-test3; /* or names of variables if different*/

     array newtest New_test1 - New_test3; /* make sure the number of elements match the number of "test" variables*/

     do j=1 to dim(test);

          new_test = test/10;

     end;

     drop j;

run;

achufa
Calcite | Level 5

Hi ballardw

thanks for reply.  But I am new to JSL and can't realy understand your suggestion.

Here is an example, please see two tables below.  Could you please kindly make a JMP table with the script and send to me?

thanks

Alex

Original data: contains 3 columns of numeric values

 

POPULATION  TEST 1 TEST 2 TEST3

TRAIN           0.65    0.62    0.63

TEST             0.67    0.64    0.68

TEST             0.65    0.62    0.65

TRAIN           0.69    0.64    0.67

TRAIN           0.69    0.66    0.66

TRAIN           0.67    0.66    0.66

TEST             0.69    0.66    0.68

TRAIN           0.65    0.62    0.63

TRAIN           0.67    0.66    0.66

TRAIN           0.65    0.62    0.64

TRAIN           0.65    0.64    0.64

TRAIN           0.65    0.62    0.64

TEST             0.65    0.62    0.66

TRAIN           0.65    0.64    0.65

TEST             0.71    0.64    0.67

TEST             0.65             

TRAIN           0.69    0.66    0.66

TRAIN           0.63    0.62    0.63

TRAIN           0.67    0.62    0.65

TRAIN           0.67    0.64    0.65

TRAIN           0.67    0.64    0.66

TEST             0.65    0.64    0.65

TRAIN           0.65    0.64    0.65

Need data:

based on each of 3 test data columns, I need to make 3 additional columns, one for each test column, which will contain the formula, for example DELTA 1 = :TEST 1 / 10;   DELTA 2 = :TEST 2 / 10;  DELTA 3 = :TEST 3 / 10;

as following:

POPULATION  TEST1 TEST2 TEST3 DELTA1  DELTA2   DELTA3

TRAIN            0.65    0.62    0.63   0.065   0.062   0.063

TEST             0.67    0.64    0.68    0.067   0.064   0.068

TEST             0.65    0.62    0.65    0.065   0.062   0.065

TRAIN           0.69    0.64    0.67    0.069   0.064   0.067

TRAIN           0.69    0.66    0.66    0.069   0.066   0.066

TRAIN           0.67    0.66    0.66    0.067   0.066   0.066

TEST             0.69    0.66    0.68    0.069   0.066   0.068

TRAIN           0.65    0.62    0.63    0.065   0.062   0.063

TRAIN           0.67    0.66    0.66    0.067   0.066   0.066

TRAIN           0.65    0.62    0.64    0.065   0.062   0.064

TRAIN           0.65    0.64    0.64    0.065   0.064   0.064

TRAIN           0.65    0.62    0.64    0.065   0.062   0.064

TEST             0.65    0.62    0.66    0.065   0.062   0.066

TRAIN           0.65    0.64    0.65    0.065   0.064   0.065

TEST             0.71    0.64    0.67    0.071   0.064   0.067

TEST             0.65                        0.065            

TRAIN           0.69    0.66    0.66    0.069   0.066   0.066

TRAIN           0.63    0.62    0.63    0.063   0.062   0.063

TRAIN           0.67    0.62    0.65    0.067   0.062   0.065

TRAIN           0.67    0.64    0.65    0.067   0.064   0.065

TRAIN           0.67    0.64    0.66    0.067   0.064   0.066

TEST             0.65    0.64    0.65    0.065   0.064   0.065

TRAIN           0.65    0.64    0.65    0.065   0.064   0.065

ballardw
Super User

By JSL are running JUMP by any chance? There is a different forum for that.

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
  • 5 replies
  • 958 views
  • 0 likes
  • 3 in conversation