Now,
I have the following dataset
I need to create a variable called 'Perfectshot'
let perfect shot=PS
1. if all prevously viewable image become 'nonviewable'
and
2. Goodimage = Yes --> becomes 'nonviewable' or measures <10
compare each day to the day1 image
please help!
You need to format this post, your table spills over and it doesn't display properly.
For me at least, on Chrome.
Sorry about that..I have attached my table with this post
Thanks!
Many users here don't want to download Excel files because of virus potential, others have such things blocked by security software. Also if you give us Excel we have to create a SAS data set and due to the non-existent constraints on Excel data cells the result we end up with may not have variables of the same type (numeric or character) and even values.
If you have an existing SAS dataset to share then this link: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...
will show how to generate datastep code that you can post or attach as a text file to provide data wo work with.
person_id | visitday | Viewable_1 | length_1 | Goodimage_1 | Viewable_2 | lengthe_2 | Goodimage_2 | Viewable_3 | length_3 | Goodimage_3 |
1 | day1 | Yes | 36 | No | Yes | 15 | Yes | Yes | 15 | No |
1 | day2 | Yes | 19 | No | Yes | 31 | Yes | Yes | 18 | No |
1 | day3 | Yes | 28 | No | Yes | 27 | Yes | Yes | 30 | No |
2 | day1 | Yes | 38 | No | Yes | 15 | No | Yes | 49 | Yes |
3 | day1 | Yes | 47 | No | Yes | 14 | No | Yes | 41 | Yes |
3 | day2 | Yes | 78 | No | . | . | . | . | . | . |
4 | day1 | Yes | 74 | No | . | . | . | . | . | . |
4 | day2 | Yes | 8 | No | Yes | 7 | No | . | . | . |
4 | day3 | Yes | 8 | No | Yes | 7 | No | Yes | 12 | No |
5 | day1 | Yes | 3 | No | Yes | 23 | Yes | . | . | . |
5 | day2 | Yes | 8 | No | Yes | 15 | Yes | . | . | . |
5 | day3 | Yes | 7 | No | Yes | 13 | Yes | . | . | . |
5 | day4 | Yes | 7 | No | Yes | 11 | Yes | . | . | . |
5 | day5 | Yes | 6 | No | no | 11 | Yes | . | . | . |
6 | day1 | Yes | 16 | No | no | 12 | Yes | . | . | . |
6 | day2 | Yes | 17 | No | Yes | 12 | Yes | . | . | . |
7 | day1 | Yes | 6 | No | Yes | 6 | Yes | . | . | . |
7 | day2 | No | . | No | Yes | 5 | Yes | . | . | . |
8 | day1 | No | . | No | Yes | 6 | Yes | . | . | . |
8 | day2 | No | . | No | Yes | 6 | Yes | . | . | . |
9 | day1 | Yes | 16 | No | . | . | . | . | . | . |
9 | day2 | . | . | . | . | . | . | . | . | . |
10 | day1 | Yes | 21 | No | . | . | . | . | . | . |
10 | day2 | Yes | 24 | Yes | Yes | 24 | yes | Yes | 33 | No |
10 | day3 | Yes | 26 | Yes | Yes | 26 | No | Yes | 54 | No |
11 | day1 | no | 27 | Yes | Yes | 26 | No | . | . | . |
11 | day2 | Yes | 10 | No | Yes | 31 | Yes | Yes | 44 | No |
11 | day3 | Yes | 56 | No | . | . | . | . | . | . |
12 | day1 | Yes | 43 | No | . | . | . | . | . | . |
12 | day2 | Yes | 41 | No | . | . | . | . | . | . |
12 | day3 | Yes | 40 | No | . | . | . | . | . | . |
13 | day1 | Yes | 34 | No | . | . | . | . | . | . |
Unfortunately i don thave an existing sas dataset
I will create one and post it
person_id | visitday | Viewable_1 | length_1 | Goodimage_1 | Viewable_2 | lengthe_2 | Goodimage_2 | Viewable_3 | length_3 | Goodimage_3 |
1 | day1 | Yes | 36 | No | Yes | 15 | Yes | Yes | 15 | No |
1 | day2 | Yes | 19 | No | Yes | 31 | Yes | Yes | 18 | No |
1 | day3 | Yes | 28 | No | Yes | 27 | Yes | Yes | 30 | No |
2 | day1 | Yes | 38 | No | Yes | 15 | No | Yes | 49 | Yes |
3 | day1 | Yes | 47 | No | Yes | 14 | No | Yes | 41 | Yes |
3 | day2 | Yes | 78 | No | . | . | . | . | . | . |
4 | day1 | Yes | 74 | No | . | . | . | . | . | . |
4 | day2 | Yes | 8 | No | Yes | 7 | No | . | . | . |
4 | day3 | Yes | 8 | No | Yes | 7 | No | Yes | 12 | No |
5 | day1 | Yes | 3 | No | Yes | 23 | Yes | . | . | . |
5 | day2 | Yes | 8 | No | Yes | 15 | Yes | . | . | . |
5 | day3 | Yes | 7 | No | Yes | 13 | Yes | . | . | . |
5 | day4 | Yes | 7 | No | Yes | 11 | Yes | . | . | . |
5 | day5 | Yes | 6 | No | no | 11 | Yes | . | . | . |
6 | day1 | Yes | 16 | No | no | 12 | Yes | . | . | . |
6 | day2 | Yes | 17 | No | Yes | 12 | Yes | . | . | . |
7 | day1 | Yes | 6 | No | Yes | 6 | Yes | . | . | . |
7 | day2 | No | . | No | Yes | 5 | Yes | . | . | . |
8 | day1 | No | . | No | Yes | 6 | Yes | . | . | . |
8 | day2 | No | . | No | Yes | 6 | Yes | . | . | . |
9 | day1 | Yes | 16 | No | . | . | . | . | . | . |
9 | day2 | . | . | . | . | . | . | . | . | . |
10 | day1 | Yes | 21 | No | . | . | . | . | . | . |
10 | day2 | Yes | 24 | Yes | Yes | 24 | yes | Yes | 33 | No |
10 | day3 | Yes | 26 | Yes | Yes | 26 | No | Yes | 54 | No |
11 | day1 | no | 27 | Yes | Yes | 26 | No | . | . | . |
11 | day2 | Yes | 10 | No | Yes | 31 | Yes | Yes | 44 | No |
11 | day3 | Yes | 56 | No | . | . | . | . | . | . |
12 | day1 | Yes | 43 | No | . | . | . | . | . | . |
12 | day2 | Yes | 41 | No | . | . | . | . | . | . |
12 | day3 | Yes | 40 | No | . | . | . | . | . | . |
13 | day1 | Yes | 34 | No | . | . | . | . | . | . |
Here is the data
Thanks!
Here is the sas dataset
I hope someone can help me with this
thanks!
Now in terms of that data you need to expand on:
1. if all prevously viewable image become 'nonviewable'
and
Previous to what? Lower index variable in the same row? Previous rows for same day? Previous days?
It may seem obvious to you but your data does not have a "nonviewable" value. What is the definition of nonviewable in this context? Does this apply to multiples of the variables Viewable_1, Viewable_2 and Viewable_3 on one row (and how many), or across rows or across days?
2. Goodimage = Yes --> becomes 'nonviewable' or measures <10
compare each day to the day1 image
Yor example data above does not have a variable Measures. What does Measures<10 mean in terms of the data above?
Since you have 3 variables named GoodImage then which one? And what does Goodimag=1 becomes 'nonviewable' mean? Point to an example in the data.
And given that input, what does the result look like?
Hi,
I have tried to better explain here
If all [viewable] = no
Or
Day 1 [Goodimage 1,2,3 ] =no and [viewable 1,2,3]=yes now becomes [Goodimage 1,2,3 ] =no
And and [viewable 1,2,3]=no
Or
Day1 [Goodimage 1,2,3 ] =yes and [viewable 1,2,3]=yes now becomes [Goodimage 1,2,3 ] =yes
and [viewable 1,2,3]=no or [viewable 1,2,3]=yes and [length 1,2,3] <10
Thanks!
By your short hand like this: [Goodimage 1,2,3 ] =no do you mean "the value for all 3 of the variable is no"?
So nothing is done for Day 2 if at least one "viewable" = Yes?
At this point I am not sure if you are specifying your requirement for all Day 1 records or this process is to be done for each record.
You really need to show your results as your requirement:
if all [viewable] = no
Or
Day 1 [Goodimage 1,2,3 ] =no and [viewable 1,2,3]=yes now becomes [Goodimage 1,2,3 ] =no
And and [viewable 1,2,3]=no
Or
Day1 [Goodimage 1,2,3 ] =yes and [viewable 1,2,3]=yes now becomes [Goodimage 1,2,3 ] =yes
and [viewable 1,2,3]=no or [viewable 1,2,3]=yes and [length 1,2,3] <10
is very poorly stated.
Computers want clearly defined boundaries. From your statement portion:
if all [viewable] = no (what is done in this case )
Or
Day 1 [Goodimage 1,2,3 ] =no and [viewable 1,2,3]=yes now becomes [Goodimage 1,2,3 ] =no (why do you even specify this as it is apparently a contion to get here)
And and [viewable 1,2,3]=no
Or
Day1 [Goodimage 1,2,3 ] =yes and [viewable 1,2,3]=yes now becomes [Goodimage 1,2,3 ] =yes
and [viewable 1,2,3]=no OR (HOW do we know to use the assignment before the OR or after the Or in this block) [viewable 1,2,3]=yes and [length 1,2,3] <10 (you have apparently one set of conditions but two different results [viewable 1,2,3]=no and [viewable 1,2,3]=yes)
I think you are using OR in a non-computer sense. Computer programs look like :
If A or B then do this:
Else IF C or D then do this;
Else Do something else.
Please show the actual desired output based on your input as the logic you are using is either incomplete or inconsistent. You may know what the desired outcome is but cannot speak "computer" well enough to describe what you are attempting.
And what value should be assigned to your variable "perfectshot"?
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.