BookmarkSubscribeRSS Feed
yabwon
Onyx | Level 15

Hey SAS-L,

 

The XCMD is turned off.

 

Is there a way to convince SAS to, when running DREA(), DNUM() etc. functions, see hidden files too? 

 

Something like:

x 'DIR /A';

under Windows

or

filename f PIPE 'ls -a';

under Linux or UNIX systems,

but without OS level interaction.

 

All the best

Bart

 

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



13 REPLIES 13
JosvanderVelden
SAS Super FREQ
Hi Bart, have a look at this paper to see if it gives you ideas on how to approach your challenge: http://www8.sas.com/scholars/Proceedings/2006/Applications/AP16_06.PDF
Best regards, Jos
yabwon
Onyx | Level 15

Hi Jos,

 

Thanks for the article but it wont help.  It uses X statement.  And, as I wrote, I have NOXCMD.

 

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



JosvanderVelden
SAS Super FREQ
Have you seen this post? https://communities.sas.com/t5/SAS-Programming/Delete-hidden-files/td-p/229878. It seems to have code using dread as you indicate. But like the solution indicates access to hidden files from within SAS using dread does not work. And my guess is that fdelete for a directory will result in an error because windows will not allow deletion of the hidden files in the directory. However I've seen some unexpected behaviour in some windows versions. I assume something like this will not work on a unix-based system.
yabwon
Onyx | Level 15

yes, I read that one too.

 

the FDELETE() will work with a hidden file, since it accepts a fileref and a fileref points to a particular object so this:

filename x "~/.test_hidden";
data _null_;
  file x;
  put "text";
run;
data _null_;
  rc = fdelete('x');
run;

will work ok (I did a test on linux)

 

So if you have a list of hidden files you will be able to delete them, thing is to get that list with DOPEN, DREAD, DNUM, etc.

 

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



mkeintz
PROC Star

Here's a random thought:

 

Does/would your system administrator permit use of some single other SAS session that allows XCMD with access to the same data storage as your sas session?  Can that session be configured as the server for a sas/connect client session on your end?

 

Restricting access to that server might be a way for sysadmins to maintain desired authorization restrictions, while you (as an authorized user) can have your sas/connect client use the server as a proxy for the needed xcmd actions.

--------------------------
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

--------------------------
yabwon
Onyx | Level 15

Hi Mark,

 

Well, it's not that easy.

 

I was thinking about a general solution, in particular this macro: https://github.com/SASPAC/baseplus/blob/main/baseplus.md#dirsandfiles-macro which is OS independent solution, with no XCMD needed, but lacks that "see hidden files" feature. 

 

I was hoping that there is some SAS option which I missed that allows for such a "in depth" view. Unfortunately it looks like there is no way to do it without an OS access.

 

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



lexjansen
Obsidian | Level 7

Hi Bart,

 

Did you ever find a solution to this?

I'm trying to delete a folder structure cloned from GitHub, that contains  .gitignore and .gitkeep files.

I'm running into the same issue.

 

Thanks,

Lex

yabwon
Onyx | Level 15

Unfortunately I didn't find one 😞 😞

Unless you have XCMD enabled and will to run OS commands, SAS functions won't help you.

I also doubt that asking SAS for development will work... 😞

 

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



yabwon
Onyx | Level 15

Voted 👍

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



lexjansen
Obsidian | Level 7
Thanks, Kurt!
lexjansen
Obsidian | Level 7

My original use-case was being able to delete a folder structure cloned from GitHub.

I was not able to do this, because the folder structure contained hidden files like .gitkeep and .gitignore.

It turns out that the GIT_DELETE_REPO function does exactly what I was looking for.

The GIT_DELETE_REPO function deletes a specified local Git repository and all of the contents inside that repository.

And actually, the function does not seem to care whether the folder is a Git folder. It will just delete any folder structure.

 

data _null_;
RC = GIT_DELETE_REPO('/home/lexjansen/dataset-json-sas');
put RC=;
run;
Reeza
Super User
That's a fun workaround to delete a folder with files in it 😄

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 13 replies
  • 1153 views
  • 10 likes
  • 6 in conversation