BookmarkSubscribeRSS Feed
saitejaguduru97
Calcite | Level 5

Hi All,

 

I have a data be like

 

Data Da1;
input Id Drug$ Dose;
datalines;
101 Da 200
101 Da 200
101 Da 200
102 Da 200
102 Da 200
102 Da 200
103 Da 200
103 Da 200
;run;

 

I am expecting the output be like:

 

Id        F1
------------
101     Y
102     N
103     Y

 

Please help me out in the program to get an output.

 

Thank you

10 REPLIES 10
PaigeMiller
Diamond | Level 26

Please explain how the column named F1 in the output is computed from the data you show.

--
Paige Miller
saitejaguduru97
Calcite | Level 5
We have to create F1 row.
PaigeMiller
Diamond | Level 26

@saitejaguduru97 wrote:
We have to create F1 row.

I asked you to explain how the column F1 is calculated. You have not explained this.

--
Paige Miller
saitejaguduru97
Calcite | Level 5
Expecting output be like:
Id Drug Dose F1
101 Da 200 Y
102 Da 200 N
103 Da 200 Y..

I need the program code F1 is the variable name or else you can take any name.
PaigeMiller
Diamond | Level 26
I am going to put emphasis on the key words in my question, since you don't seem to be grasping the question. The emphasized words are in capital letters.

HOW IS F1 CALCULATED?
--
Paige Miller
saitejaguduru97
Calcite | Level 5
I think with the use of First.id and last.id
PaigeMiller
Diamond | Level 26
Tell us in words how you compute F1, do not use SAS code, just words.
--
Paige Miller
Patrick
Opal | Level 21

The sample data you provide is identical for Drug and Dose in all rows. 

What could possibly be the logic one would need to implement to derive a column F1 from this data that gets N for id 102 but Y for the other two id's.

Patrick_0-1672240647311.png

 

Please explain the logic to be used. ...and likely provide better sample data that matches the desired result once logic applied.

 

saitejaguduru97
Calcite | Level 5
See for example:-
Here 3 patients are there they came to the visits and now I need 101 and 103 patients first visit only for first visit the value should be Y and For 102 subject I want only last visit and for that value should be N
PaigeMiller
Diamond | Level 26
Why is 101 and 103 a Y and 102 a N? What is the logic? what is the reason? How would we know which is Y and which is N?
--
Paige Miller

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