Appreciate if someone of you validate whether the following code respect to the SAS syntax? Since I do not have access to SAS enviornment at the moment I'm unable to validate it. As the following code has link statement, I'm not sure that the code which I updated is valid.
If you honestly and sincerely wrote this code which one may agree considering your proc star status, nonetheless your question raises doubt whether you really wrote the code. On the other hand, supposing you did, what's the problem in checking syntax by yourself.
With reference to many of your previous questions, I'm afraid the legitimacy of your questions seem very doubtful
I've updated the code and not written the full code which was in OP. I have updated the same in OP.
I don't see any problems with your use of LINK. I even use GOTO and all the kids think GOTO is taboo.
There are a couple of things
schrijfh:
*schrijf weg met huidige gegevens;
p2kbrn='7';
if substr(khiref,1,1) = '1' then
do;
file outfr14a noprint notitles; *File statement use redundand as FT14OUTH has file statement;
link fr14outh;
end;
if substr(khiref,1,1) = '2' then
do;
file outfr14b noprint notitles; *same redundand;
link fr14outh;
end;
else if substr(khiref,1,1) = '0' then
do;
file outfr14 noprint notitles; *same again;
link fr14outh;
end;
return;
fr14outh :
file '$FSAGDU/data/transport/out/qis_dwh/QISFR10_c.txt' lrecl=64;
put @1 khiref $20
@21 kndbtpDB $10
@31 knkbty $2.
@33 knkatv $2.
@35 knkath $2.
@37 knabew 3.
@40 psi 9.
@49 gnksec $9.
@58 agi 6.
;
output; *remove you are using DATA _NULL_;
return;
run;
I've commented about in the code here. I think you have an unclosed DO block I'll see if I can figure that.
Good morning Guru @data_null__, Doesn't Goto 's return take you to the next iteration of the datastep as opposed to the link return?
Am i missing something in my understanding>?
@novinosrin wrote:
Good morning Guru @data_null__, Doesn't Goto 's return take you to the next iteration of the datastep as opposed to the link return?
Am i missing something in my understanding>?
LINK is GOTO and RETURN to jump point.
GOTO is just jump.
the HEADER= option in the FILE statement is an implied LINK.
the EOF= option in the INFILE statement is and implied GOTO.
I don't know if that helps. 🙂
You really should do the first pass of unit testing yourself. This would show you that there is an unclosed DO block (=missing end statement).
Below...
else knkbty='5';
knkatv = '';
knkath = '';
link schrijfh;
end;
return;
return;
Should be:
else knkbty='5';
knkatv = '';
knkath = '';
link schrijfh;
end;
end;
return;
Also below bit looks to me logically not right:
end;
else if substr(khiref,1,1) = '0' then
do;
file outfr14 noprint notitles;
link fr14outh;
end;
return;
fr14outh :
file '$FSAGDU/data/transport/out/qis_dwh/QISFR10_c.txt' lrecl=64;
put @1 khiref $20
You have code like file outfr14 noprint notitles; in your code (I assume that there is somewhere a filename statement which defines this fileref). You then link directly to fr14out where you issue another file statement - which will overwrite the previous file statement AND you always link to fr14out from your if/then/else blocks meaning that always the same code writing to the same file will get executed - which renders your if/then/else rather useless as they always result in identical code being executed.
@Allaluiah wrote:
If you honestly and sincerely wrote this code which one may agree considering your proc star status, nonetheless your question raises doubt whether you really wrote the code. On the other hand, supposing you did, what's the problem in checking syntax by yourself.
With reference to many of your previous questions, I'm afraid the legitimacy of your questions seem very doubtful
@Allaluiah if your criticism of @Babloo is in regards to use of the LINK statement I suggest you are mistaken.
I hope your future sake that you really don't update production code if you don't validate the logic yourself.
basic debuggers help to identify issues. At times you can learn what the prior programmer was intending to do by stepping a few records through the logic.
https://communities.sas.com/t5/SAS-Programming/use-of-index/m-p/264460#M51865
It is hard for me to read that hanging indentation style. For example you have indented lines after IF statements (so the structure implies you have added a DO block) but when I scan the left margin to find the corresponding END there is nothing before another statement starts on the same indentation as the IF. That is not a problem per se, it just makes it harder to scan the code.
You do have one instance that looks strange where if you have
if substr(khiref,1,1) = '1' then
if substr(khiref,1,1) = '2' then
else if substr(khiref,1,1) = '0' then
Since the value cannot be both '1' and '0' it is probably ok, but it looks strange to not have ELSE before the second IF in that construct.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: