Dear member,
Could you please help me in below query:
input
Data one;
input all $50. ;
datalines;
ram is "amazing"
shyan needs "/books/lamps"
we are "/travellling/"
;
run;
I need output dataset New having values like this in a new variable two.
two
amazing
/books/lamps
/travellling/
Hmm No wonder not participating here enough makes me lose touch consequential in not thinking of the following in the 1st place. Jeez!--
Data one;
input all $50. ;
datalines;
ram is "amazing"
shyan needs "/books/lamps"
we are "/travellling/"
;
run;
data two;
set one;
length want $50;
want=scan(all,-2,'"');
run;
proc print noobs;run;
| all | want |
|---|---|
| ram is "amazing" | amazing |
| shyan needs "/books/lamps" | /books/lamps |
| we are "/travellling/" | /travellling/ |
Data one;
input all $50. ;
datalines;
ram is "amazing"
shyan needs "/books/lamps"
we are "/travellling/"
;
run;
data two;
set one;
length want $50;
_k=findc(all,'"','b');
_k1=findc(all,'"')+1;
want=substr(all,_k1, _k-_k1);
drop _k:;
run;
proc print noobs;run;
| all | want |
|---|---|
| ram is "amazing" | amazing |
| shyan needs "/books/lamps" | /books/lamps |
| we are "/travellling/" | /travellling/ |
Hmm No wonder not participating here enough makes me lose touch consequential in not thinking of the following in the 1st place. Jeez!--
Data one;
input all $50. ;
datalines;
ram is "amazing"
shyan needs "/books/lamps"
we are "/travellling/"
;
run;
data two;
set one;
length want $50;
want=scan(all,-2,'"');
run;
proc print noobs;run;
| all | want |
|---|---|
| ram is "amazing" | amazing |
| shyan needs "/books/lamps" | /books/lamps |
| we are "/travellling/" | /travellling/ |
@novinosrin wrote:
Hmm No wonder not participating here enough makes me lose touch consequential in not thinking of the following in the 1st place. Jeez!--
Data one; input all $50. ; datalines; ram is "amazing" shyan needs "/books/lamps" we are "/travellling/" ; run; data two; set one; length want $50; want=scan(all,-2,'"'); run; proc print noobs;run;
all want ram is "amazing" amazing shyan needs "/books/lamps" /books/lamps we are "/travellling/" /travellling/
Maybe we need a self-assigned badge of the "Forehead pop" for such.
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.