- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi everyone,
I have an imported dataset A and I need to get a specific cell value. Is there a way, like in other languages, to get the value by its coordinates (ex : A[4;5]) ?
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@Gluttony wrote:
Hi everyone,
I have an imported dataset A and I need to get a specific cell value. Is there a way, like in other languages, to get the value by its coordinates (ex : A[4;5]) ?
Thank you
Why? Why would you want to do such a thing? How are you going to use the value once you have it?
If you want the value of a specific variable from a specific observation there are many ways.
For example if the fifth column is named VAR5 then you could get the value for it from the fourth observation using this data step.
data want;
set have (keep=VAR5 firstobs=4 obs=4);
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your answer,
I'm creating a function with proc fcmp to apply it on B (let's say ages : 70, 71, 72, 73...), and in this function, I need to get the value associated to the age (70 for ex.) in table A and then use it with a multiplication
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
To reference a particular value in a sas dataset column can do
The conditional check itself will return a boolean value of 0 or 1. If using in a function you can use it as 70*(age=70); when age=70 the multiplication returns a 70 it will return 0 otherwise. Hope this helps.
if <colname> = value;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Is this the one where you wanted to call a macro and run some other code to get a value the function can return?
So it looks like you want to pass in three values to your macro. The NAME of the variable to sum and the upper and lower limits for the value of ID variable to include in the sum.
So an SQL query like this could be used to get the sum into the macro variable RESULT.
proc sql noprint;
select sum(&varname) format=best32. into :result trimmed
from MYTABLE
where ID between &LOWER and &UPPER
;
quit;