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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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