Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6117203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:17:38+00:00 2026-05-23T15:17:38+00:00

I am trying my hand at SAS macros for the first time. My basic

  • 0

I am trying my hand at SAS macros for the first time. My basic question is: I have a dataset with some 10000 variables. I need to take each column individually, create a new conditional variable, store the results, then move to the next column. These columns are not sequentially ordered. What is the syntax SAS uses to identify a column (similar to how “_N_” would identify a row)?

Here is more information.
The data looks something like this:

ID  v1   v2   v3  ... v10000
01  3.2  1.5  7.8 ...   4.2
02  1.1  4.5  1.9 ...  10.7
..
 N  2.5  1.5  4.9 ...   7.3

I need to look at the values of v1, count how many obs are above a value x and how many are below a value x, record those numbers in a dataset, then move onto v2, v3, … v10000. In the end, I’d have a dataset that would show the number of obs above value x and number of obs below value x for each of my 10000 variables.

I have written the code as I would have written it for one variable in standard SAS code and it works, and now my intention is to convert that code into macro code, but I do not know how to construct a loop that would move from one column to the next.

Any help or references you could give would be greatly appreciated.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:17:38+00:00Added an answer on May 23, 2026 at 3:17 pm
    %LET CUTOFF = 3.1415926 ; /* set this as your 'cutoff' value */
    
    data counters ;
      set mydata end=eof ;
    
      array vi{*} v1-v10000 ; /* incoming values */
      array vc{*} c1-c10000 ; /* counters */
    
      retain vc . ;
    
      do i = 1 to dim(vi) ;
        if vi{i} >= &CUTOFF then vc{i} + 1 ;
      end ;
    
      if eof then output ;
    
      keep c1-c10000 ;
    run ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying my hand at optimising some code I have using microsoft's sse
Trying my hand at Mac Cocoa for the first time. Lion and XCode 4.1.
I'm trying to make a function that will take short hand hex color to
I've been trying my hand at OO PHP, and currently have three files. I
I was trying my hand at Google Code Jam and there was a question
I'm trying my hand in learning Regular Expressions in Oracle ( rather, my first
recently I have been trying my hand at coding a game in C#. I'm
So I'm trying my hand at some C++ after finishing up an introductory book,
inspired by Clojure, and Peter Norvig I have been trying my hand at implementing
Trying my hand at some simple firefox extensions... I am trying to create a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.