Hello~
I am trying to replace blanks (which were not noted as '.', see attachment, line5, line8-9, line13-14) with 'NA' by if location =' ' then 'NA'; but nothing happened. Please help. Thank you!
There are some unprintable character other than white blank.
data x;
location=' ';output;
location='09'x;output;
location='xxxxxx';output;
run;
data x;
set x;
if prxmatch('/^\s+$/',location) then new='NA ';
else new=location;
run;
You can try missing function:
IF Missing(Location) then Location = 'NA';
run;
thank you for the quick response!
but it doesn't work......T.T
Post your code and log please
Besides, how could I extract the location between <dt>Location</dt> <dd> and </dd>? (see attachment)
data testlocation;
filename indata url 'http://forums.vwvortex.com/showthread.php?7286873-To-our-readers' lrecl=10000;
infile indata length=len;
input record $varying10000. len;
input @ '<dt>Join Date</dt> <dd>' / location :&$10000. ;
if location = ' ’ then location = ‘NA’;
data order_location;
set work. testlocation;
rank_num=_n_;
run;
There are some unprintable character other than white blank.
data x;
location=' ';output;
location='09'x;output;
location='xxxxxx';output;
run;
data x;
set x;
if prxmatch('/^\s+$/',location) then new='NA ';
else new=location;
run;
I just adapted
if prxmatch('/^\s+$/',location) then new='NA ';
else new=location;
a little bit. It worked! thank you Ksharp.
@may0423 wrote:
see attachment
A picture attachment is not helpful. If we want to mock up code we have to manually type out your data. If you have blank characters besides spaces there's no way to check.
Post as text or a SAS dataset but posting an image is not very useful.
filename indata url 'http://forums.vwvortex.com/showthread.php?7286873-To-our-readers' lrecl=10000;
data testlocation;
infile indata length=len;
input record $varying10000. len;
retain start;
if record =: '<body>' then start=1;
if start then do;
record=prxchange('s/\<[^\<\>]+\>//',-1,record);
if not prxmatch('/^\s+$/',record) then output;
end;
run;
data want;
set testlocation;
lag=lag(record);
if prxmatch('/^\s*View Profile/',record) then do;record=lag;output;end;
if prxmatch('/^\s*(Join Date|Location|Posts)/',record) then output;
run;
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.