Hi,
Seeking for help in fixing the errors as found in this code.
proc sql; create table pledge9 as select a.*, b.waterfall_frb_ny from pledge8 as a left join PledgeDataLoanLevel5 as b on a.loan_number2 = b.loan_nb ; quit ; proc freq data = pledge9; tables waterfall3 * waterfall_frb_ny / list missing ;run;
Screenshot of Errors
Thanks,
Cykelops
Please post proc contents of the datasets involved.
hi @andreas_lds
How should I do that? like this >>
proc contents data = PledgeDataLOanLevel5; run;
Cykelops
Yes, and for both datasets involved. You need to check if the variables you are using exist and are of same type (the vars used in the join)
Hi @andreas_lds
I am trying to insert the proc contents pledge9 or PledgeDataLoanlevel5 but it gives me syntax error. I am not really good in this and I need your guidance on this.
Please advise.
Maxim 1: Read the Documentation.
I provided a link to the documentation of the CONTENTS procedure. Use it.
In the future, don't post pictures of code or logs. Copy/paste the text into a window opened with these buttons:
The one indicated is for logs and other fixed-format text (like the contents of csv files), the "little running man" right next to it for SAS code.
And take care to post the whole shebang. In your picture, the important line is cut off.
I guess that you missed to use the DATA= option of the PROC CONTENTS statement.
Thanks for the correction. Additional question, is this proc contents data can be inserted anywhere in the code? In my understanding, we do this in order to determine the variable use (like its source excel file).
@Cykelops wrote:
Thanks for the correction. Additional question, is this proc contents data can be inserted anywhere in the code? In my understanding, we do this in order to determine the variable use (like its source excel file).
SAS programs consists of STEPS. You can have DATA steps and PROC steps.
You can place a PROC CONTENTS step anywhere you want as long you you don't try to place it in the middle of another step in your program. If you are using PROC IMPORT to read in an external file that you have never read before then a PROC CONTENTS step right after the PROC IMPORT step makes sense so that you can check that it is the data you were expecting.
You use PROC CONTENTS to determine the structure of a dataset before you write the code processing the dataset. That's what Maxim 3 means: know your data before you work with it.
If you want code to work repeatedly and seamlessly with newly arriving input, the data must be of consistent structure.
Since you are inflicted with the typical consequences of careless use of "simple" software (Excel is anything but in reality!), you must work hard with the source of the data to get more consistent input data. This may need to involve the application of a LART.
Maxim 3: Know Your Data.
Run PROC CONTENTS on the dataset(s), but a quick view by opening the dataset interactively will already show you the variable names.
Right-clicking on something (dataset or column) in the user interface will also enable you to show the properties.
Exactly the same problem as in your other thread https://communities.sas.com/t5/New-SAS-User/Error-Variable-not-Found/m-p/942814#M42332
Same data set, same proc contents result, no variable named LOAN in the data set. The wording is different because Proc Sql behaves a bit differently and you could have created the variable where the reference to the alias B was used.
Example that selects a variable with one name into a new name:
proc sql; select b.loan from (select name as loan from sashelp.class) as b ; quit;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.