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
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.