Hello. Everyone,
115 %include 'C:\Users\thisi\Documents\slreg.sas' /source2; WARNING: Physical file does not exist, C:\Users\thisi\Documents\slreg.sas. ERROR: Cannot open %INCLUDE file C:\Users\thisi\Documents\slreg.sas.
You cannot refer to a folder/file that does not exist. You have to refer to a folder/file that does exist. If you look in Windows Explorer, you will see that no file named slreg.sas exists in the folder.
Your macro is not stored as a SAS file. It is stored in a SAS catalog named DOC. I believe you should just call the macro, without %include.
Hello. Paige,
Thank you for your reply.
Actually, both this folder path
C:\Users\thisi\Documents\
and the catalog sasmacr exist.
This is why the error seems confusing.
@xtan2 wrote:
Hello. Paige,
Thank you for your reply.
Actually, both this folder pathC:\Users\thisi\Documents\and the catalog sasmacr exist.
"catalog sasmacr exist" — but that's not what I said. And that's not what you told SAS to look for.
SAS is looking for a file named slreg.sas in that folder. Why? Because that's what you said to look for in the %include statement. And it's not in there.
You can access your macro without %include. Just use
%slreg(newyear2010, dep=sale, indep=day)
without any %include (you may have to restart SAS, because it is now looking for the %slreg macro elsewhere, perhaps there is a way to eliminate this problem without restarting SAS, but I am not aware of the method).
Yes. I have successfully use this code:
%slreg(newyear2010, dep=sale, indep=day)
It works well.
But we were asked to do the following:
In the year2010 data, consider sale as your response variables, day as your independent variable. Write a sas macro for simple linear regression by considering (sale and day as the dependent and independent variable) and store it. Call this regression by following approaches
When I tried to call the saved macro of slreg, none of the strategies have worked. So I posted my question here.
To get %include to work, you specifically have to save the macro in a file named slreg.sas in that folder. It doesn't work if there isn't a file named slreg.sas in that folder.
This is the confusing point: I have already created the macro slreg and it exists:
Do I have to change the type of this macro from Macro into SAS?
You want a file type of .sas
Changing the file type of the file you just showed will not work. You have to save the macro as text, with file name slreg.sas
Is the image of the "sasmacr" that makes you think your file is there?
That's a catalog file, not a .sas file. I would recommend changing your Windows viewer settings so you can see the extensions on the file or add the file type in the viewer. Then you'll see the file type is not a SAS program file, it's a SAS catalog with an extension of sas7bcat. So your %include is looking for a file with the extension ".sas". It will be the program file from your first post, saved to the location below.
So the %INCLUDE doesn't work because there is no .sas file there.
This is how that solution would work:
%include 'path to .sas file with macro code';
%slreg(newyear2010, dep=sale, indep=day);
@xtan2 wrote:
Hello. Paige,
Thank you for your reply.
Actually, both this folder pathC:\Users\thisi\Documents\and the catalog sasmacr exist.
This is why the error seems confusing.
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!
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.