Help using Base SAS procedures

How to use a variable from data step as criteria

Reply
Regular Contributor
Posts: 240

How to use a variable from data step as criteria

hi I have a. Data step thatcreates a column name of day of week mon tue wed thur...

i Have a table that will depend on whatever the column generates a filter for that

here is my syntax for the criteria for table

From Step1

where week contain Some=? .;

need help in how to make refer to output from week an make it a criteria ...

TThanks

Super User
Super User
Posts: 6,500

Re: How to use a variable from data step as criteria

So is the variable (column) named WEEK?  And what does the column actually contain?  Is it the text 'mon' or 'tue' like in your question?  Is the case consistent?

Then your selection criteria would look like

where upcase(week) in ('MON','TUE')

or

where upcase(week) in ('WED','FRI')

Or do you in fact have multiple variables (columns) with names like MON, TUE, WED ?  If so then what do they contain?  Are they numbers or character strings.

Let's assume they are numbers with zero or missing meaning false and another value meaning true then your selection criteria looks like:

where MON or TUE ;

or

where WED or FRI ;

Regular Contributor
Posts: 240

Re: How to use a variable from data step as criteria

HI Tom

yes the data step will create the column "week"  and depending on yesterday day it will populate Mon or Tue or Wed or Thu or Fri .... then my table will into my criteria a filter for that

from Step1

where schedule contain = ?

I Don't know how to refer to my output from the data step week example for today it would pull Tue

so I need contain to eq Tue and tomorrow it should refer Wed  .....I need to be like a macro. Where there is no manual intervention... Thanks for help

Super User
Super User
Posts: 6,500

Re: How to use a variable from data step as criteria

Why do you need a WHERE clause if it is just going to load the data then report it?

Are you asking how to generate the string Wed if today is a Wednesday?

where WEEK = "%sysfunc(today(),downame3)"


Or if YESTERDAY was a Wednesday?

where WEEK = "%sysfunc(putn(%sysfunc(today())-1,downame3))"

Regular Contributor
Posts: 240

Re: How to use a variable from data step as criteria

hi Tom

i have a data step that creates the yesterday day of the week  example today I would get  Wed....the name of that column is week

i I have another table that is looking into a schedule that looks like this

SChedule

Mon Wed Thu

Tue Wed Fri Sat

WEd Fri

WEd thu Sat

tue thu fri

mon Tue. Sat

what I need is on the second table I need to refer what the output was from the date step. For example if the output was Wed

then on the 2nd table I want to pull only were there is refer toWed ...

second table

i able I will need

ffrom. Table1

where schedule =week (wed) this could Mon ,Tue,Wed Thu,Fri..... So I will do a search for contain for that date of week....

Regular Contributor
Posts: 240

Re: How to use a variable from data step as criteria

TThanks Tom I fig it out

Ask a Question
Discussion stats
  • 5 replies
  • 300 views
  • 3 likes
  • 2 in conversation