BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
novinosrin
Tourmaline | Level 20

You really need tor review your SET statement dataset calls 

 

Play with some values to see distinct values 

 


proc sql;

select distinct rand_group

from have;

quit;



/*or a */

proc freq data=have;

tables rand_group;

run;

 

 

The above will give you an idea what's in your dataset to eventually know what to expect

GS2
Obsidian | Level 7 GS2
Obsidian | Level 7
This is the output from the proc freq of the data set I am using in the set statement

rand_group Frequency Percent Frequency Percent
Treatment A  27  50.94  27  50.94
Treatment B  26  49.06   53  100.00

Frequency Missing = 477

 

novinosrin
Tourmaline | Level 20

Ok so I suppose you got the same for 

Proc sql;

select distinct rand_group

from have

quit;

 

as well.

 

In that case , you are definitely not referencing the correct dataset that picks yes/no from mars or moon lol 

GS2
Obsidian | Level 7 GS2
Obsidian | Level 7

Proc sql;

select distinct rand_group

from SPIES.SPIES_ANALYSIS_DEMOS

quit;

 

proc freq data = SPIES.SPIES_ANALYSIS_DEMOS;

table rand_group;

run;

 

Both show only treatment group a and b

 

data SPIES_ANALYSIS_DEMOS2;
do _n_=1 by 1 until(last.study_id);
set SPIES.SPIES_ANALYSIS_DEMOS;
by study_id;
if _n_=2 then _temp=Rand_group;
end;
do _n_=1 to _n_;
set SPIES.SPIES_ANALYSIS_DEMOS;
by study_id;
if _n_=1 then Rand_group=_temp;
output;
end;
drop _:;
run;

 

I am setting it to the same data set that is showing only treatment a and b 

novinosrin
Tourmaline | Level 20

And is it still show YES, NO? 

 

If it does, can you check upstream thoroughly. And if it is not confidential that would violate security/compliance, can you attach your sas dataset here? So I can work on it

GS2
Obsidian | Level 7 GS2
Obsidian | Level 7

Still has a yes/no. I cannot release my data set. Thank you for the help but I am going to use an if/then statement and manually fill in the data. 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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
  • 20 replies
  • 4381 views
  • 1 like
  • 2 in conversation