BookmarkSubscribeRSS Feed
Sudtej
Calcite | Level 5

HI,

Name  F1 F2 F3 F4 F5 F6 .. . ..
1Cycle  34 35 23 23 12 89
2Cycle 78 90 78 57 45 67
3Cycle 67 87 45 43 89 64
.
.
.
10cycle 56 45 79 90 45 78


I am having a data set like above which has a whole month data(here I have just spcified 7 columns)
I want to retrive 3rd row data which is fixed and column will be chnaging on the day basis and after retriving the value, assign the value into
a macro variable.
for ex  on 4th feb it should select (row 3 and F4 column)=value should give 43
           on the 24th feb (row 3 and F24 column)

Let me know if i am not enough clear.

Thanks

Sudtej

3 REPLIES 3
Haikuo
Onyx | Level 15

Not sure if this is what you want. Following code will put the value of the third row, column(days) you choose into macro variable 'want'.

data have;

input Name $  F1 F2 F3 F4 F5 F6 ;

cards;

1Cycle  34 35 23 23 12 89

2Cycle 78 90 78 57 45 67

3Cycle 67 87 45 43 89 64

;

%macro test (d=);

data _null_;

n=3;

set have point=n;

call symput ('want',f&d);

stop;

run;

%put &want;

%mend;

%test (d=6)

Edit:

For more general purpose, the code can also be slightly tweaked like the following, so you can also choose the row of your will.

%macro test (r= ,c=);

data _null_;

n=&r;

set have point=n;

call symput ('want',f&c);

stop;

run;

%put &want;

%mend;

%test (r=2, c=3)

Regards,

Haikuo

art297
Opal | Level 21

How is the code supposed to know that February is represented on the 3rd record?  What do records one and two represent?  Do you just want to indicate the date upfront and have the code take care of everything else?

Sudtej
Calcite | Level 5

Thanks. It works!

The whole table is for February, its one of the sheets of a workbook. The records 1, 2, 3 are different types of data which i receive on that particular day. So, I just modified your code to take the date as input & code is taking care of everything.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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