BookmarkSubscribeRSS Feed
🔒 This topic is locked. We are no longer accepting replies to this topic. Need further help? Please sign in and ask a new question.
jason4sas
Obsidian | Level 7

I was computing a temp variable with proc imstat: 

 

crosstab re_subj*bigsmall/ tempnames=bigsmall tempexpress="if number='big' then bigsmall='bigger ';

else bigsmall='smaller';";

run;

 

The values for 'smaller' is 1-character shorter, i.e. 'smalle' instead.  Therefore, I assume it is a variable length problem, like in data step.  Is there any way to fix the issue in proc imstat.

 

Thanks

6 REPLIES 6
Cynthia_sas
Diamond | Level 26
Hi:
If you are using one of the classes in the SAS Academy for Data Science, can you explain what module you're in, what course and lesson you're working one and the demo or exercise where you encountered issues?

That will provide the Data Science instructors with the information they need.
Thanks, in advance,
Cynthia
jason4sas
Obsidian | Level 7

Sure.  Here is the info:

 

module:  Module 2: Big Data Programming and Loading

course:   Getting Started with SAS® In-Memory Statistics

lesson:   Chapter 3 Exercise 2-b

 

Thanks

Cynthia_sas
Diamond | Level 26
Thanks for the information, we can ask the instructors who teach the course what they recommend. Stay tuned!
Cynthia
Cynthia_sas
Diamond | Level 26

Hi:

  What the instructors said was that:

"There is no way to control the length of a temp variable in IMSTAT, that I know of. You have to use different logic to work your way into it. I would advise them to reverse the logic. The longer variable value is now assigned first and should fix the issue.

 

tempexpress="if number NE 'big' then bigsmall='smaller ';

else bigsmall='bigger';";

 

  By putting the larger value first, the length will be set based on the length of the first string in the assignment for the BIGSMALL variable."

 

  Hope this helps,

Cynthia

jason4sas
Obsidian | Level 7

Many thanks for the solution.  Alternatively, can blank spaces be used to pack it up like this?

 

tempexpress="if number NE 'big'

                                 then bigsmall='bigger  ';

                                 else bigsmall='smaller';";

 

There is an empty space after the text in 'bigger'.  it should also work, right?

 

Jason

Cynthia_sas
Diamond | Level 26
Hi, Jason:
I would guess it should work that way. However, I do not know whether IMSTAT trims trailing blanks. You'll just have to test it to see.
Cynthia