DATA Step, Macro, Functions and more

creating a dataset

Reply
N/A
Posts: 0

creating a dataset

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
Super Contributor
Super Contributor
Posts: 3,174

Re: creating a dataset

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.
N/A
Posts: 0

Re: creating a dataset

Thanks for giving response.


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






Thanks and regards
sairam
Super Contributor
Super Contributor
Posts: 3,174

Re: creating a dataset

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.
Ask a Question
Discussion stats
  • 3 replies
  • 119 views
  • 0 likes
  • 2 in conversation