Hello team,
if I have data as
data mystestdata; set fromthissorted by memberID; if first.memberID then output; Run;
if first.memberID means from the grouped data, only read the first memberID from the group?
Please advise me.
Respectfully,
blueblue
@GN0001 wrote:
Hello team,
if I have data as
data mystestdata; set fromthissorted by memberID; if first.memberID then output; Run;if first.memberID means from the grouped data, only read the first memberID?
Please advise me.
Respectfully,
blueblue
After you correct the code so that the Set statement has a terminating semicolon ...
Not read, when encountered. This will "read" all the records in the data set(s) on the Set statement.
If the data is sorted by the By variable then only the records that are the first for each value of the by variable will be written to the output data set. If not sorted an error will be thrown.
Hello ballardw,
When you say: " that are the first for each value of the by variable will be written to the output data set"
Do you mean the first for each group?
Please let me know.
Thanks,
blueblue
@GN0001 wrote:
Hello ballardw,
When you say: " that are the first for each value of the by variable will be written to the output data set"
Do you mean the first for each group?
Please let me know.
Thanks,
blueblue
Each distinct value of a BY variable constitutes a group.
You would do well to teach yourself. Besides reading the documentation, try running a test program. Here is an example:
data mystestdata;
set fromthissorted;
by memberID;
first = first.memberID;
last = last.memberID;
Run;
proc print;
var memberID first last;
run;
READ
THE
DOCUMENTATION
the link to which (this particular documentation!) I already gave you.
And apply Maxim 4. Try It.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.