BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mona4u
Lapis Lazuli | Level 10

Hi, 

I have this dataset  and this is the result I desire 

 

Task_NameAssigned_Toresultcount
Admin QC[email protected]Admin QC 
Image Preview[email protected]Image Preview 
Admin QC[email protected]Admin QC 
Image Preview[email protected]Image Preview 
Admin QC[email protected]Admin QC 
Image Preview[email protected]Image Preview 
Photo Image Preview QC[email protected]Photo Image Preview QC 
Admin QC[email protected]Admin QC 
Image Preview[email protected]Image Preview 
Admin QC[email protected]Admin QC 
Image Preview[email protected]Image Preview 
Admin QC[email protected]Admin QC 
Image Preview[email protected]Image Preview 
Admin QC[email protected]Admin QC 
Image Preview[email protected]Image Preview 
Admin QC[email protected]Admin QC 
Image Preview[email protected]Image Preview 
Admin QC[email protected]Admin QC 
Image Preview[email protected]Image Preview 
Admin QC[email protected]Admin QC 
Image Preview[email protected]Image Preview 
Admin QC[email protected]Admin QC 
Image Preview[email protected]Image Preview 
Admin QC[email protected]Admin QC 
Image Preview[email protected]Image Preview 
Admin QC  1`
Admin QC[email protected]Admin QC 
Image Preview[email protected]Image Preview 
irRC RECIST Oncology[email protected]  
Post Pre-Derm QC[email protected]Post Pre-Derm QC 
Post Review QC 1[email protected]Post Review QC 1 
Post Review QC 2[email protected]Post Review QC 2 
Pre-Dermatology[email protected]Pre-Dermatology 
Radiology Review 1[email protected]  
Radiology Review 2[email protected]  
irRC RECIST Oncology   


and I want an idea to get the result I want  

If the scan if  scan(assigned_to,2,"@")="clinical.com"  then result=assigned_to; 

I want to create a variable that has the values that associated with the clinical.com  email from the variable assigned_to  

but also I want  to create a variable called count witch count the blanks in the assigned_to variable if the value is in the result variable 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Create your list then first:

 

proc sql noprint;
select distinct quote(task_name) into :task_list separated by ", "
from have
where email like '%@clinical.com';
quit;
%put &task_list;

If the macro variable is  too long you'll need a different approach.

View solution in original post

21 REPLIES 21
mkeintz
PROC Star

Could you

 

  1. Put the incoming data in the form of a sas data set, and
  2. (really important) show what you want the resulting data set to look like.

 

 

 

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
ballardw
Super User

Suggestion would be to cut the example data by maybe half.

Then show the desired result as well, which should be easier with the reduced set.

Reason for showing the desired result is the phrase "has the values that associated with the clinical.com email" is not exactly clear.

Does this mean that you want to do something with the "task_name" variable? Get the user name from such as tcollins from the string [email protected] or something else.

 

Since each record could only have 1 "blank" what you actually want to count appears to be something else, possibly a summary after this data set is created.

mona4u
Lapis Lazuli | Level 10

I just edited my post. 

this is a sample data has only one blank but my real data has more 

Reeza
Super User

Why not use FIND/INDEX instead of SCAN, since you're searching for a specific string set.

mona4u
Lapis Lazuli | Level 10
This point it doesn't really matter
mona4u
Lapis Lazuli | Level 10
edited it
Reeza
Super User

if find('@clincial.com', assigned_to, 'i')>0 then result=task_name;

 

 

Isn't that all you need?

mona4u
Lapis Lazuli | Level 10
I don't have a problem with this part
I have a problem with the variable count
I need to create count to count how many blanks are they if the values in the variable result without specifying the values of the variable result each time I run the program
Reeza
Super User

IF/THEN/DO.

Adding on to my previous answer, change it to conditional so that you can add the count. You only show one value of 1, so not sure why the rest are blank or if you want them incremented or something. If so, use RETAIN. If you cannot get it working at this point, post your code. 

 

if <condition> then do;

<multiple sas statements>;
count=1; end;

Please be much more clear in your initial question. 

 

http://documentation.sas.com/?docsetId=lestmtsref&docsetTarget=n0el0y2a02ab1ln1pks3gbac1en3.htm&docs...

mona4u
Lapis Lazuli | Level 10
I know if then do
the question is
if then always need to specify a value of the variable to subset
I want to specify the variable that has all those values but without mentioning the values
Reeza
Super User

@mona4u wrote:
I know if then do
the question is
if then always need to specify a value of the variable to subset
I want to specify the variable that has all those values but without mentioning the values

I have no idea what that means.

mona4u
Lapis Lazuli | Level 10
I mean usually, we subset this way
if var=a and var1=" " then count
if var in ("a", "b") and var1=" " then count


but the code that I need is
if the value in the var then count without specifying the value of the variable
Reeza
Super User

Yeah, still not following. Show me 5 lines of data and exactly what you want as output - as two different data sets. 

 


@mona4u wrote:
I mean usually, we subset this way
if var=a and var1=" " then count
if var in ("a", "b") and var1=" " then count


but the code that I need is
if the value in the var then count without specifying the value of the variable

 

mona4u
Lapis Lazuli | Level 10

 

dataset 

Task_NameAssigned_To
Admin QC[email protected]
Image Preview[email protected]
Admin QC[email protected]
Image Preview[email protected]
Admin QC[email protected]
Image Preview[email protected]
Photo Image Preview QC[email protected]
Admin QC[email protected]
Image Preview[email protected]
Admin QC[email protected]
Image Preview[email protected]
Admin QC[email protected]
Image Preview[email protected]
Admin QC[email protected]
Image Preview[email protected]
Admin QC[email protected]
Image Preview[email protected]
Admin QC[email protected]
Image Preview[email protected]
Admin QC[email protected]
Image Preview[email protected]
Admin QC[email protected]
Image Preview[email protected]
Admin QC[email protected]
Image Preview[email protected]
Admin QC 
Admin QC[email protected]
Image Preview[email protected]
irRC RECIST Oncology[email protected]
Post Pre-Derm QC[email protected]
Post Review QC 1[email protected]
Post Review QC 2[email protected]
Pre-Dermatology[email protected]
Radiology Review 1[email protected]
Radiology Review 2[email protected]
irRC RECIST Oncology 

 

 

result I desire 

Task_NameAssigned_Toresultcount
Admin QC[email protected]Admin QC 
Image Preview[email protected]Image Preview 
Admin QC[email protected]Admin QC 
Image Preview[email protected]Image Preview 
Admin QC[email protected]Admin QC 
Image Preview[email protected]Image Preview 
Photo Image Preview QC[email protected]Photo Image Preview QC 
Admin QC[email protected]Admin QC 
Image Preview[email protected]Image Preview 
Admin QC[email protected]Admin QC 
Image Preview[email protected]Image Preview 
Admin QC[email protected]Admin QC 
Image Preview[email protected]Image Preview 
Admin QC[email protected]Admin QC 
Image Preview[email protected]Image Preview 
Admin QC[email protected]Admin QC 
Image Preview[email protected]Image Preview 
Admin QC[email protected]Admin QC 
Image Preview[email protected]Image Preview 
Admin QC[email protected]Admin QC 
Image Preview[email protected]Image Preview 
Admin QC[email protected]Admin QC 
Image Preview[email protected]Image Preview 
Admin QC[email protected]Admin QC 
Image Preview[email protected]Image Preview 
Admin QC  1`
Admin QC[email protected]Admin QC 
Image Preview[email protected]Image Preview 
irRC RECIST Oncology[email protected]  
Post Pre-Derm QC[email protected]Post Pre-Derm QC 
Post Review QC 1[email protected]Post Review QC 1 
Post Review QC 2[email protected]Post Review QC 2 
Pre-Dermatology[email protected]Pre-Dermatology 
Radiology Review 1[email protected]  
Radiology Review 2[email protected]  
irRC RECIST Oncology   

 

 

 

 

CFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

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
  • 21 replies
  • 5780 views
  • 6 likes
  • 4 in conversation