why variable did not get created in data cleaning?

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 131
Accepted Solution

why variable did not get created in data cleaning?

Hi! I have a question about why a variable I created is not being read.  In the following program, I create the dataset partic_cln from partic.  In one of the steps, I'd like to create a binary variable NoServices (line 1048) and then at the end of my cleaning, make sure to drop all records for which NoServices=1.  Do you know why this is not working?  My code is below. Many thanks in advance! 1033      data partic_cln (drop = name); 1034      set partic; 1035      1036      *Clean Participant Last Name, First Name; 1037      lastname_prs = propcase(scan(name,1,",")); 1038      firstname_prs = strip(propcase(scan(name,2,","))); 1039      1040      *Creating a copy of Participant Last, First Name to preserve for the link file; 1041      lastname_prs_link = propcase(scan(name,1,",")); 1042      firstname_prs_link = strip(propcase(scan(name,2,","))); 1043      1044      /* NoServices is a 0/1 variable created to flag ISIS participants who were RA'd but never 1044    ! received services. 1045      Records flagged as one may still appear in PRS extracts and the BIF.  For example, 1045    ! B_unique_ID1 IL10491 is a participant 1046      who has been RA'd but does not receive services.  He/she is still in BIF file, however.*/ 1047      1048      NoServices=0; 1049      if B_unique_ID1="IL10491" then NoServices=1; 1050      1051      *Include PRS hardcodes program; 1052      %include "S:\Projects\ISIS\Admin Data\PRS\02 Programs\prs_clean01_prs bif hardcode.sas"/. . . NOTE: %INCLUDE (level 1) ending. ERROR: Variable NoServices is not on file WORK.PARTIC. 1145      1146      where NoServices ne 1; 1147      run;


Accepted Solutions
Solution
‎10-17-2014 11:51 AM
Super User
Super User
Posts: 6,323

Re: why variable did not get created in data cleaning?

ERROR: Variable NoServices is not on file WORK.PARTIC


So only these two lines are relevant to the error message.


  set partic;

where NoServices ne 1;


If you think the the variable NOSERVICES should already be on the input dataset then look upstream for the error.

If instead you are intending the WHERE clause to change the records that are OUTPUT instead of the records that are INPUT then you probably want to change it from WHERE to IF.



View solution in original post


All Replies
Grand Advisor
Posts: 17,332

Re: why variable did not get created in data cleaning?

You need to reformat that code so it's readable...

Frequent Contributor
Posts: 131

Re: why variable did not get created in data cleaning?

code1.PNGHey Reeza,

Yep - do you have any suggestions for how I can paste code without using the HTML box option?

I ve attached an image of the portion of my code I have a question about.  the error I receive is:

ERROR: Variable NoServices is not on file WORK. PARTIC

Let me know if I should elaborate or clarify

Thanks!

Grand Advisor
Posts: 17,332

Re: why variable did not get created in data cleaning?

Use a different browser, not IE, or copy paste to Word/Notepad and then to here.

I've never seen a %include inside a data step like that.  I'm not sure that's valid either, what are you expecting that piece of code to do? Perhaps move that to before your data step if you're expecting it to create a format or some data set that should exist?

Solution
‎10-17-2014 11:51 AM
Super User
Super User
Posts: 6,323

Re: why variable did not get created in data cleaning?

ERROR: Variable NoServices is not on file WORK.PARTIC


So only these two lines are relevant to the error message.


  set partic;

where NoServices ne 1;


If you think the the variable NOSERVICES should already be on the input dataset then look upstream for the error.

If instead you are intending the WHERE clause to change the records that are OUTPUT instead of the records that are INPUT then you probably want to change it from WHERE to IF.



Frequent Contributor
Posts: 131

Re: why variable did not get created in data cleaning?

Hi Tom -

The NOSERVICES var shouldn't be in the input dataset; I create it in the output/new dataset, partic_cln.  using 'IF  NoServices=1 then delete;

worked and I had a problem elsewhere too.

Thanks!

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 195 views
  • 3 likes
  • 3 in conversation