Dear All,
I need to execute a linux command and from de result create a data set:
%macro psawk;
%sysexec %str(ps aux | awk '{print $1,$2,$3,$6,$11}' >/SASData/test11.txt);
%mend psawk;
%psawk;
from this I get a file with the following structure
Regards,
Abraham
Assign filename to the file created by the command and read it into sas:
filename result '/SASData/test11.txt';
data want;
infile result truncover firstobs=2;
input user $ @;
if user = "USER" then do; input; return; end; /* skip 1st line */
input pid cpu rss command $;
run;
thanks for all your help
Assign filename to the file created by the command and read it into sas:
filename result '/SASData/test11.txt';
data want;
infile result truncover firstobs=2;
input user $ @;
if user = "USER" then do; input; return; end; /* skip 1st line */
input pid cpu rss command $;
run;
Thanks for your answer, it it works but I have a problem in the command column just put a fragment and not the complete information, this field can have up to 400 characters.
Regards
The default length is 8.
Change the $ after command to $400. (include the dot).
Why create the text file at all?
data want;
infile "ps aux | awk '{print $1,$2,$3,$6,$11}'" pipe firstobs=2 truncover ;
input user :$40. pid cpu rss command $500.;
run;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.