BookmarkSubscribeRSS Feed
kate-1mr
Obsidian | Level 7

Здравствуйте, я новый пользователь и хочу, чтобы кто-нибудь помог мне с моей проблемой. Извините, если мой вопрос простой, но я не могу этого понять. У меня есть символьная переменная, которая выглядит так, как показано ниже, я пытаюсь преобразовать, но, к сожалению, у меня отсутствует значение.

data one;

x='2017M08';

x2=input(strip(x),yymm7.);

run;

Я пробую несколько других способов, как показано ниже: но все еще отсутствуют значения data one;

x='2017M08';

x2=input(x,anydtdte.);

run;

Я пытаюсь найти решение моей проблемы с функцией сжатия, и я конвертировал, но не уверен, что этот метод правильный

data one;

x='2017M08';

x1=compress(x,'M');

x2=input(x1,6.);

run;

Может ли кто-нибудь объяснить мне, какую информацию я должен нам использовать для преобразования символьного значения в числовое, если символьное значение представляет собой '2019M09'? Я готовлюсь к экзамену и хочу знать и понимать как можно больше. Спасибо.

2 REPLIES 2
PaigeMiller
Diamond | Level 26

There is no YYMM7. informat. There is a YYMMN. informat that you can use, but you have to remove the letter M from the text string, as follows:

 

data one;
x='2017M08';
x2=input(compress(x,'M'),yymmn6.);
format x2 yymm7.;
run;

 

 

--
Paige Miller
kate-1mr
Obsidian | Level 7

ok. I understood. Thank you so much:). 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 452 views
  • 1 like
  • 2 in conversation