Hi, How can I split this text into multiple columns:
"TEST","N/A","Week One","Disabled","Disabled","Disabled","Disabled"
"TEST","N/A","MON, TUE, WED, THU, FRI","Disabled","Disabled","Disabled","Disabled"
"TEST","N/A","Week One","Disabled","Disabled","Disabled","Disabled"
"TEST","N/A","Stop On Battery Mode, No Start On Batteries","Disabled","Disabled","Disabled","Disabled"
The result in this example should be 7 columns
TEST | N/A | Week One | Disabled | Disabled | Disabled | Disabled |
TEST | N/A | MON, TUE, WED, THU, FRI | Disabled | Disabled | Disabled | Disabled |
TEST | N/A | Week One | Disabled | Disabled | Disabled | Disabled |
TEST | N/A | Stop On Battery Mode, No Start On Batteries | Disabled | Disabled | Disabled | Disabled |
So this text is in a single variable now? Or is this in a separate file?
In a SAS data set, correct? Not an external file like csv?
Sas Data looks like
From where does that data originate? This clearly looks like a line from a CSV file, so it should be read initially as such.
Then you can do it right there:
data want;
infile "schtasks /fo csv" pipe dlm="," dsd end=eof;
input
name :$10.
var2 :$5.
when :$40.
var4 :$10.
var5 :$10.
var6 :$10.
var7 :$10.
;
run;
Adapt variable names and formats as needed.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.