But got it but i can do like that as we will run on a server .Can u do the same by infile <path>
Thqs
The file comma_data.txt is located in SAS Server?
If it were, let Administrator of SAS give your absolute path Like: /home/myfile/comma_data.txt
and make sure you have privilege to read this file.
then use
filename x temp;
data _null_;
file x;
length row $ 400;
retain row;
infile '/home/myfile/comma_data.txt';
input;
row=cats(row,_infile_);
if countc(row,'"') ge 20 then do;put row; call missing(row);end;
run;
data want;
infile x dsd;
informat a b c d e f g h i j $200.;
input a$ b$ c$ d$ e$ f$ g$ h$ i$ j$ ;
run;
Ksharp
ksharp can we cant do like this
data work;
length row $ 400;
retain row;
infile '/home/myfile/comma_data.txt';
input;
row=cats(row,_infile_);
if countc(row,'"') ge 20 then do;put row; call missing(row);end;
run;
data want;
infile work dsd;
informat a b c d e f g h i j $200.;
input a$ b$ c$ d$ e$ f$ g$ h$ i$ j$ ;
run;
Your code won't work because you created work as a sasfile, not a text file. Did you try the method that Ksharp had proposed?
It was working but can we do the way i have given
Short answer, no! You could open 'work' with a set statement and then use the scan function to retrieve the delimited fields contained within the variable row.
But why would you, when Ksharp's proposed method is a lot cleaner and easier?
As Arthur said. You need to my whole original code .
filename x temp;
data _null_;
file x;
length row $ 400;
retain row;
infile '/home/myfile/comma_data.txt';
input;
row=cats(row,_infile_);
if countc(row,'"') ge 20 then do;put row; call missing(row);end;
run;
data want;
infile x dsd;
informat a b c d e f g h i j $200.;
input a$ b$ c$ d$ e$ f$ g$ h$ i$ j$ ;
run;
Ksharp
Why? Why do you have to make a dataset not a temporary file?
data work; length row $ 400; retain row; infile 'c:\comma_data.txt'; input; row=cats(row,_infile_); if countc(row,'"') ge 20 then do;output; call missing(row);end; keep row; run; data want; set work; a=scan(row,1,'"','m'); b=scan(row,2,'"','m'); c=scan(row,3,'"','m'); d=scan(row,4,'"','m'); e=scan(row,5,'"','m'); f=scan(row,6,'"','m'); g=scan(row,7,'"','m'); h=scan(row,8,'"','m'); i=scan(row,9,'"','m'); j=scan(row,10,'"','m'); run;
Ksharp
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.