BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Maisha_Huq
Quartz | Level 8

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;

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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

5 REPLIES 5
Reeza
Super User

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

Maisha_Huq
Quartz | Level 8

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!

Reeza
Super User

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?

Tom
Super User Tom
Super User

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.



Maisha_Huq
Quartz | Level 8

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!

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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