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

Here is my code:

 

 

libname file0 'x/y/z';

 

data _null_;

yest = today() -1;

a = 'hamming_';

call symput('inventions',put("file0.",$6.)||put(a,$8.)||put(yest,yymmddn8.));

options symbolgen;

run;

 

data temp0;

set &inventions (obs=1);

run;

 

proc print data=temp0;

run;

 

symbolgen returns 'file0.hamming_20180417'

and i get an error in the set statement saying FILE 'file0.hamming_20180417.DATA' does not exist.

 

How can I remove this '.DATA'?

 

Thanks,

Jon

 

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

Is file0.hamming_20180417 a SAS dataset? If it isn't, you can't access it with a set statement.

 

Art, CEO, AnalystFinder.com

 

View solution in original post

13 REPLIES 13
art297
Opal | Level 21

You should get more errors than the one you showed as there were other errors in your code. And I think an extra space was imbedded in the file name. The following worked for me:

libname file0 '/folders/myfolders';

data _null_;
  yest = today() -1;
  a = 'hamming_';
  call symput('inventions',put("file0.",$6.)||put(a,$8.)||put(yest,yymmddn8.));
  options symbolgen;
run;

data &inventions.;
  set sashelp.class;
run;

data temp0;
  set &inventions (obs=1);
run;

proc print data=temp0;
run;

Art, CEO, AnalystFinder.com

 

prolifious
Obsidian | Level 7

thank you, yes in masking my actual program i made a couple errors, but i think i corrected them as you were responding...thank you!!

 

Anyway, can you please explain the structure:

 

data &inventions. ;

    set sashelp.class;

run;

 

whats going on there?  why do i need it?  I'm not questing if it should be there, i would just like to understand a bit on it.

 

Thanks,

Jon

prolifious
Obsidian | Level 7

this is not working for me.  I still get the message from the set statement noting "xyz.DATA" does not exist, but the symbolgen produces the precise var that i want.

art297
Opal | Level 21

Since your code was trying to open an existing file, I simply created that file using the datastep to create it with a copy of sashelp.class.

 

Unless you changed your symbolgen to match the one in my code, it was actually creating a macro variable that contained:

file0.hamming_ 20180417

A dataset name cannot include an imbedded blank.

 

My code, on the other hand, produced:

file0.hamming_20180417

Art, CEO, AnalystFinder.com

 

prolifious
Obsidian | Level 7

yes, i corrected that error.  the code listed in my initial comment is fixed, and reflects my actual program.  thank you.  It still does not work.  is the variable being capitalized when referencing my file?  my file name is all lower case.

prolifious
Obsidian | Level 7

i notice in the log that everything is capitalized in the FILE 'FILE0....DATA' does not exist statement, but my actual file is all lower-case.  do i need to constrict it to lower-case?

art297
Opal | Level 21

No. The log is simply showing it as uppercase, but it is actually lowercase.

 

Art, CEO, AnalystFinder.com

 

art297
Opal | Level 21

Is file0.hamming_20180417 a SAS dataset? If it isn't, you can't access it with a set statement.

 

Art, CEO, AnalystFinder.com

 

Astounding
PROC Star

Based on the questions you are asking, you have been seriously misled.  This is not a good project for you.  It is unreasonable, dangerous, and should be postponed for 6 months until you have more experience using SAS language.

 

Macro language generates SAS programs.  You need more experience with SAS, to be able to visualize what a working SAS program looks like.  Even if your macro code runs without error, you won't know whether the program it generates is good or bad.  It is just too early in the game to be worrying about macro language.

prolifious
Obsidian | Level 7

I must say, you're comment here struck a nerve with me.  At first, i was kind of upset - how could they?  But then I realized, maybe what this person is really trying to do is motivate me.  So, I took to proving you wrong so that I could get to where I need to be.  In that, I was proving that the var generated for the set statement was as it should be....and it is.  I checked with a prog that already has it, and the file location itself.  it all matched.  but i was sitll getting the error...then it donned on me to check the libname statement.  i did and discovered i left out the leading forward slash.  i put that in and everything is icecream.  you're right though, i should have known that the .DATA is a feature of the message, not what was actually being executed.  I won't forget that the next time around.  before i hang my head in shame, i just want to thank you, and anyone else who's attempted to help my mistake here.  i shall not forget this episode.  ok, now im hanging my head...................................and I'm done. moving on.   thanks again.

Astounding
PROC Star

You did well on all counts.  No head-hanging needed.

 

Your next step on the road (if you haven't done this already) is to omit a semicolon, then try to figure out why the statement that follows is invalid.

 

Best of luck.

Kurt_Bremser
Super User

The extension .DATA is always appended when a dataset name is included in the log. This can't be removed, as it is a given property of the SAS logger.

(if you were reading a view, the extension would be .VIEW, for example)

 

Your data _null_ code can be greatly simplified:

data _null_;
yest = today() -1;
call symput('inventions',"file0.hamming_"||put(yest,yymmddn8.));
run;

Note that no put() is needed for character variables, if you use them. But consider the use of strip() to remove leading and trailing blanks.

 

For the error, look if a file

hamming_20180418.sas7bdat

exists in directory

x/y/z

(or whatever is your real location).

SAS dataset filenames must be lowercase(!) in the file system, although SAS always spells them out in uppercase in the logs or in resources like dictionary.tables. That is a remnant of SAS's mainframe roots (where everything is uppercase), and the migration to UNIX (where filenames are mostly lowercase, and case-sensitive).

SAS Innovate 2025: Register Now

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!

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