BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi,

i have a dataset A and it consists 3 variables id, samp , score.

data A;
input id $ samp score ;
datalines;
1002345A 1 .
1003678A 1 .
3 1 708
4 1 .
5 1 .
10 2 .
11 2 807
12329874H 2 .
12 2 .
1 3 907
23456899J 3 .
;

i want an output : id variable length greater then 5 and by group of samp variable, the score value must be equals to that ID variable.

the output should be in the following way:

output:

id samp score
1002345A 1 708
1003678A 1 .
12329874H 2 807
23456899J 3 907
3 REPLIES 3
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Are you asking a question, posing a problem, or simply wanting someone to do the work for you? Have you made any attempt to program in SAS the task you describe in your post?

Your post mentions "score value must be equals to that ID variable" yet the desired output you share with the forum does not match this condition.

From what I see, it appears that you want to use some technique to group your data on the SAMP variable, capturing the "last" (or maybe first?) non-missing SCORE variable value, but only if contributed by an observation having an ID variable in length greater than 5 characters.

An additional SAS DATA step could be used against your data set "A", after first sorting the data, and using a RETAIN statement to save the SCORE value in another variable when the appropriate ID and SAMP variable conditions are met.


Scott Barry
SBBWorks, Inc.
deleted_user
Not applicable
Thanks for giving response.


I am posing a problem ; i need a code for getting the output:






Thanks and regards
sairam
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Might I encourage your interest to attempt some coding, post it to the forum for discussion/feedback, as an opportunity to learn more about the SAS language?

Scott Barry
SBBWorks, Inc.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1170 views
  • 0 likes
  • 2 in conversation