DATA Step, Macro, Functions and more

x statement output

Accepted Solution Solved
Reply
Contributor
Posts: 22
Accepted Solution

x statement output

Dear all,

How can i send output of x statement into

a dataset. By using the below code the dataset is created

but i am unable to open the dataset.

X 'man bdf>>/sys/man.sas7bdat';

X 'bdf>>/sys/bdf.sas7bdat';


Accepted Solutions
Solution
‎02-22-2012 11:55 AM
Trusted Advisor
Posts: 1,301

x statement output

Posted in reply to KarthikSrivasthav

'bdf' and 'df' are pretty much the same thing, they have a different default block-size is all, I think.  The 'man' command requests the manual information for a command, and I cannot be sure what purpose this is being called for.

KarthikSrivasthav wrote:

X 'man bdf>>/sys/man.sas7bdat';

X 'bdf>>/sys/bdf.sas7bdat';

These commands will create two text files in /sys/ with the erronious extention of sas7bdat.  Just using the sas dataset extention does not convert this output to a valid data format for SAS.

The way you will want to accomplish this task is to use filename statement with the pipe engine to read the stdout from the system commands into a SAS data step.

filename foo pipe 'df -hTP';

data foo;

infile foo lrecl=512 firstobs=2 truncover;

input (filesystem type size used avail usepct mounted_on) (:$64.);

run;

View solution in original post


All Replies
Regular Contributor
Posts: 233

x statement output

Posted in reply to KarthikSrivasthav

It would help if you can post more details. what do you have in 'bdf'?

Contributor
Posts: 22

x statement output

Bdf or df  command will give details about data usage and the percent of data occupied

in the server according to directory and file wise

Regular Contributor
Posts: 233

x statement output

Posted in reply to KarthikSrivasthav

The best approach would be moving the results to text file and then converting the text file to data set. Give it a try.

Contributor
Posts: 22

x statement output

Hima i already tried that way i got the result

But i need to send directly to a sas data set

Regular Contributor
Posts: 233

x statement output

Posted in reply to KarthikSrivasthav

Can you post the results of man bdf? It would greater visibilty for me to help you solve this.

PROC Star
Posts: 7,468

x statement output

Posted in reply to KarthikSrivasthav

I don't know what man or bdf do.  Do they result in sas files or text files or something else?

Solution
‎02-22-2012 11:55 AM
Trusted Advisor
Posts: 1,301

x statement output

Posted in reply to KarthikSrivasthav

'bdf' and 'df' are pretty much the same thing, they have a different default block-size is all, I think.  The 'man' command requests the manual information for a command, and I cannot be sure what purpose this is being called for.

KarthikSrivasthav wrote:

X 'man bdf>>/sys/man.sas7bdat';

X 'bdf>>/sys/bdf.sas7bdat';

These commands will create two text files in /sys/ with the erronious extention of sas7bdat.  Just using the sas dataset extention does not convert this output to a valid data format for SAS.

The way you will want to accomplish this task is to use filename statement with the pipe engine to read the stdout from the system commands into a SAS data step.

filename foo pipe 'df -hTP';

data foo;

infile foo lrecl=512 firstobs=2 truncover;

input (filesystem type size used avail usepct mounted_on) (:$64.);

run;

Contributor
Posts: 22

x statement output

Thanks

Its working

Super User
Posts: 10,020

x statement output

Posted in reply to KarthikSrivasthav

As FriedEgg said, you need PIPE .

filename x pipe 'dir c:\';
data want;
infile x length=len;
input row $varying200. len ;
run;

Ksharp

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 9 replies
  • 222 views
  • 0 likes
  • 5 in conversation