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

I am having issues associating the characters within the datalines to the do variable 'time'. can anyone assist me with that?

data new;

do time=1 to 4;

input m1-m3 @;

output;

end;

datalines;

na 4 56

bo 2 45

so 4 30

zd 1 55

;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

Create and apply either a format or informat.

You have to provide more info. Are you just trying to do something like:

proc format;

  invalue mtime

  'na'=1

  'bo'=2

  'so'=3

  'zd'=4

  ;

run;

data new;

  informat time mtime.;

  input time m2-m3;

datalines;

na 4 56

bo 2 45

so 4 30

zd 1 55

;

run;

View solution in original post

3 REPLIES 3
art297
Opal | Level 21

Not sure what you're question is, but the following will do what I think your code was trying to do:

data new;

  format time best32.;

  informat m1 $2.;

  input m1-m3;

  time=_n_;

datalines;

na 4 56

bo 2 45

so 4 30

zd 1 55

;

SasFellow331
Calcite | Level 5

I am trying to associate the characters in the first column with the 1-4 in the do "time" variable. i want to read the read the na as 1, bo as 2.

art297
Opal | Level 21

Create and apply either a format or informat.

You have to provide more info. Are you just trying to do something like:

proc format;

  invalue mtime

  'na'=1

  'bo'=2

  'so'=3

  'zd'=4

  ;

run;

data new;

  informat time mtime.;

  input time m2-m3;

datalines;

na 4 56

bo 2 45

so 4 30

zd 1 55

;

run;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1243 views
  • 0 likes
  • 2 in conversation