BookmarkSubscribeRSS Feed
leglucker
Calcite | Level 5

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 

TESTN/AWeek OneDisabledDisabledDisabledDisabled
TESTN/AMON, TUE, WED, THU, FRIDisabledDisabledDisabledDisabled
TESTN/AWeek OneDisabledDisabledDisabledDisabled
TESTN/AStop On Battery Mode, No Start On BatteriesDisabledDisabledDisabledDisabled

 

7 REPLIES 7
PeterClemmensen
Tourmaline | Level 20

So this text is in a single variable now? Or is this in a separate file?

leglucker
Calcite | Level 5
This text is in a sigle rows and 1 row looks like:
"TEST","N/A","Stop On Battery Mode, No Start On Batteries","Disabled","Disabled","Disabled","Disabled"
PeterClemmensen
Tourmaline | Level 20

In a SAS data set, correct? Not an external file like csv?

leglucker
Calcite | Level 5

Przechwytywanie.JPG

 Sas Data looks like

 

leglucker
Calcite | Level 5
Data are from Win TaskSchedule
data have;
infile "schtasks /fo csv" pipe end=eof;
input ; var= _infile_;
run;
Kurt_Bremser
Super User

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.

SAS Innovate 2025: Register Now

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!

How to connect to databases in SAS Viya

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.

Discussion stats
  • 7 replies
  • 1503 views
  • 0 likes
  • 3 in conversation