07-30-2015 09:47 PM
I have one data set contain char segment1 (first segment, second segment and third segment) and num form_quality(good, bad, average). What command I should use to subset first segment and good?
07-31-2015 03:55 AM
person id form_quality segment1
6 Good form first Segment
4 no info first Segment
7 no info third Segment
9 Average form third Segment
15 Bad form third Segment
8 no info third Segment
11 no info third Segment
I am not is this the one you requested. This somehow the data, I want only the observation with Bad form and third Segment, but the problem is form_quality is numeric data whereas segment1 is char variable.
07-31-2015 04:03 AM
If I have understood properly, then a useful way to subset a dataset is with an IF condition or a WHERE.
WHERE segment1="first segment" and form_quality>=7;
If you provide a minimum example with an example with your data, we could give a better answer
07-31-2015 09:30 AM
I say 7 because form is supose to be numeric, mi fist thoug was a numeric variable from 0-10 as exemple and depending of the value the quality is better or worse.
If your var is categoric as in your example then you could use something like the answered by MadhuKorni, or specifie the levels of the numeric format applied to form_quality
07-31-2015 06:14 AM
You mentioned form quality as Num and gave the values as good,bad, average
If its is character type then you can use any of the below code.
create table Want as
select * from Have
where upcase(segment1) = "FIRST SEGMENT" and upcase(form_quality) = "GOOD";
if upcase(segment1) = "FIRST SEGMENT" and upcase(form_quality) = "GOOD";
If you are sure about the case of the data then you can remove upcase() for both the variables.
If form_quality is Numeric then mention the number in the condition by removing the quotes.
If you have any format ( numeric to char conversion) on form_quality variable (1- good,2-average,3-bad) then use
if upcase(segment1) = "FIRST SEGMENT" and form_quality = 1;