1) I'm brand new here (and to programing) so sorry if this is in the wrong place.
2) my code keeps coming up with this message:
You have too many quotation marks. You have quotes when you use your macro variables and in your macro variable definition.
Drop the quotations marks from the macro variables.
You also need double quotes in your WHERE clause so the macro variables resolve, otherwise they won't. And that's probably why you have no results.
data cereal;
set mylib.cereal;
run;
%Let mgf1=G;
%Let mgf2=Q;
%Let Nutrient=Sodium;
title "&Nutrient affect on &mgf1. and &mgf2.";
proc ttest data=cereal h0=0 alpha=0.05 sides=2 ;
class Mgf;
where Mgf in("&mgf1","&mgf2");
var &Nutrient;
run;
I'm assuming you didn't create this dataset. Since someone else created it, if the created it on a different system you get this NOTE. It's not an issue and shouldn't affect your data.
If you want to remove it from appearing, copy your data over to work and use it from there instead.
/*Brings it into your system*/
data cereal;
set mylib.cereal;
run;
/*writes it back out as your system*/
data mylib.cereal;
set cereal;
run;
And now use cereal instead of mylib.cereal. You shouldn't see the error message anymore.
You could replace the dataset with the one you just created to remove the error entirely.
I think the quotes error is different and relates to
option validvarname = Any/V7.
Please show the complete code you used to copy the dataset and what generated the message about "zero observations". May be a spelling error in the data set name one way or another
data cereal;
set mylib.cereal;
run;
%Let mgf1='G';
%Let mgf2='Q';
%Let Nutrient=Sodium;
title "&Nutrient affect on &mgf1 and &mgf2";
proc ttest data=cereal h0=0 alpha=0.05 sides=2 ;
class Mgf;
where Mgf in('&mgf1','&mgf2');
var &Nutrient;
run;
I'm thinking it's something to do capitalization or ; or something silly. Because it wasn't reading the observations when it was in the library either.
It's possible it's case sensitive, or the library declaration is case sensitive.
If you right click the dataset and hit properties one field should have the dataset name. Use that to refer to it.
The thing is, the library worked in a different dataset. It's when I started doing %Let that it doesn't recognize the dataset
You have too many quotation marks. You have quotes when you use your macro variables and in your macro variable definition.
Drop the quotations marks from the macro variables.
You also need double quotes in your WHERE clause so the macro variables resolve, otherwise they won't. And that's probably why you have no results.
data cereal;
set mylib.cereal;
run;
%Let mgf1=G;
%Let mgf2=Q;
%Let Nutrient=Sodium;
title "&Nutrient affect on &mgf1. and &mgf2.";
proc ttest data=cereal h0=0 alpha=0.05 sides=2 ;
class Mgf;
where Mgf in("&mgf1","&mgf2");
var &Nutrient;
run;
As @Reeza already mentioned, you have a problem with quotes. Macro variables are not resolved inside single quotes.
And you should not use any quotes around values when defining macro variables, unless you want the quotes to be part of the macro variable value!
The macro preprocessor only knows the data type text, so quotes are almost never needed.
So in your example, your where condition is looking for the values &mgf1 and &mgf2, instead of the intended K and G.
Yes thank you! This was the solution 🙂 Got it all figured out before it was due luckily
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.