Fluorite | Level 6

## MOVING TO OTHER LINE BASED ON "-"(HI FUN)

data a;
input id s \$ 3-118;
datalines;
1 prg-code,main,IT-Hardware,Ins,Main,Non_IT- ,WOrk-Hardwrk,giveup,main,doit, -Nowork,ceo-cash,main,user,repair,nonit,
run;

LOGIC :I WANT TO MOVE IT IN TO ANOHTER ROW BASED ON "- "(HI FUN) BEFORE HIFUN FIRST COMMA .

i wnat it in data set a2 as

output:

1 prg-code,main
1 IT-Hardware,Ins,Main
1 Non_IT-
1 WOrk-Hardwrk,giveup,main,doit
1 -Nowork
1 ceo-cash,main,user,repair,nonit
Opal | Level 21

## Re: MOVING TO OTHER LINE BASED ON "-"(HI FUN)

Presuming hi fun represents hyphen, the following might serve the purpose. There is probably a more direct way with regular expressions, but I am still just learning those:
[pre]
data a;
informat s \$200.;
input id s &;
datalines;
1 prg-code,main,IT-Hardware,Ins,Main,Non_IT- ,WOrk-Hardwrk,giveup,main,doit, -Nowork,ceo-cash,main,user,repair,nonit,
;
run;

data a2 (keep=id want);
set a;
length want \$35;
array x (99) \$35.;
i=1;
do while (scan(s,i,',') ne "");
x(i)=scan(s,i,',');
i+1;
end;
want="";
do j=1 to i;
want=catx(',',want,x(j));
if j eq i or index(x(j+1),"-") gt 0 then do;
output;
want="";
end;
end;
run;
[/pre]
HTH,
Art
---------
> data a;
> input id s \$ 3-118;
> datalines;
> 1 prg-code,main,IT-Hardware,Ins,Main,Non_IT-
> ,WOrk-Hardwrk,giveup,main,doit,
> -Nowork,ceo-cash,main,user,repair,nonit,
> run;
>
> LOGIC :I WANT TO MOVE IT IN TO ANOHTER ROW BASED ON
> "- "(HI FUN) BEFORE HIFUN FIRST COMMA .
>
> i wnat it in data set a2 as
>
> output:
>
> 1 prg-code,main
> 1 IT-Hardware,Ins,Main
> 1 Non_IT-
> 1 WOrk-Hardwrk,giveup,main,doit
> 1 -Nowork
> 1 ceo-cash,main,user,repair,nonit
Discussion stats